@wagmi/connectors 1.0.5 → 2.0.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.
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/coinbaseWallet.mjs",
3
3
  "main": "../dist/coinbaseWallet.js"
4
4
  }
@@ -1,28 +1,28 @@
1
- import {
2
- ChainNotConfiguredForConnectorError,
3
- ConnectorNotFoundError
4
- } from "./chunk-ZCAPXGBX.js";
5
- import {
6
- normalizeChainId
7
- } from "./chunk-OQILYQDO.js";
8
- import {
9
- Connector,
10
- __privateAdd,
11
- __privateGet,
12
- __privateSet,
13
- __publicField
14
- } from "./chunk-QYMCVNHT.js";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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
+
4
+ var _chunkZCAPXGBXjs = require('./chunk-ZCAPXGBX.js');
5
+
6
+
7
+ var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
8
+
9
+
10
+
11
+
12
+
13
+
14
+ var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
15
15
 
16
16
  // src/injected.ts
17
- import {
18
- ResourceNotFoundRpcError,
19
- SwitchChainError,
20
- UserRejectedRequestError,
21
- createWalletClient,
22
- custom,
23
- getAddress,
24
- numberToHex
25
- } from "viem";
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ var _viem = require('viem');
26
26
 
27
27
  // src/utils/getInjectedName.ts
28
28
  function getInjectedName(ethereum) {
@@ -104,7 +104,7 @@ function getInjectedName(ethereum) {
104
104
  if (provider.isMetaMask)
105
105
  return "MetaMask";
106
106
  };
107
- if (ethereum.providers?.length) {
107
+ if (_optionalChain([ethereum, 'access', _ => _.providers, 'optionalAccess', _2 => _2.length])) {
108
108
  const nameSet = /* @__PURE__ */ new Set();
109
109
  let unknownCount = 1;
110
110
  for (const provider of ethereum.providers) {
@@ -118,14 +118,14 @@ function getInjectedName(ethereum) {
118
118
  const names = [...nameSet];
119
119
  if (names.length)
120
120
  return names;
121
- return names[0] ?? "Injected";
121
+ return _nullishCoalesce(names[0], () => ( "Injected"));
122
122
  }
123
- return getName(ethereum) ?? "Injected";
123
+ return _nullishCoalesce(getName(ethereum), () => ( "Injected"));
124
124
  }
125
125
 
126
126
  // src/injected.ts
127
127
  var _provider;
128
- var InjectedConnector = class extends Connector {
128
+ var InjectedConnector = class extends _chunkQYMCVNHTjs.Connector {
129
129
  constructor({
130
130
  chains,
131
131
  options: options_
@@ -136,32 +136,32 @@ var InjectedConnector = class extends Connector {
136
136
  if (typeof window === "undefined")
137
137
  return;
138
138
  const ethereum = window.ethereum;
139
- if (ethereum?.providers)
139
+ if (_optionalChain([ethereum, 'optionalAccess', _3 => _3.providers]))
140
140
  return ethereum.providers[0];
141
141
  return ethereum;
142
142
  },
143
143
  ...options_
144
144
  };
145
145
  super({ chains, options });
146
- __publicField(this, "id", "injected");
147
- __publicField(this, "name");
148
- __publicField(this, "ready");
149
- __privateAdd(this, _provider, void 0);
150
- __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
151
- __publicField(this, "onAccountsChanged", (accounts) => {
146
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "injected");
147
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name");
148
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "ready");
149
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _provider, void 0);
150
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
151
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
152
152
  if (accounts.length === 0)
153
153
  this.emit("disconnect");
154
154
  else
155
155
  this.emit("change", {
156
- account: getAddress(accounts[0])
156
+ account: _viem.getAddress.call(void 0, accounts[0])
157
157
  });
158
158
  });
159
- __publicField(this, "onChainChanged", (chainId) => {
160
- const id = normalizeChainId(chainId);
159
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
160
+ const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
161
161
  const unsupported = this.isChainUnsupported(id);
162
162
  this.emit("change", { chain: { id, unsupported } });
163
163
  });
164
- __publicField(this, "onDisconnect", async (error) => {
164
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", async (error) => {
165
165
  if (error.code === 1013) {
166
166
  const provider = await this.getProvider();
167
167
  if (provider) {
@@ -172,7 +172,7 @@ var InjectedConnector = class extends Connector {
172
172
  }
173
173
  this.emit("disconnect");
174
174
  if (this.options.shimDisconnect)
175
- this.storage?.removeItem(this.shimDisconnectKey);
175
+ _optionalChain([this, 'access', _4 => _4.storage, 'optionalAccess', _5 => _5.removeItem, 'call', _6 => _6(this.shimDisconnectKey)]);
176
176
  });
177
177
  const provider = options.getProvider();
178
178
  if (typeof options.name === "string")
@@ -195,7 +195,7 @@ var InjectedConnector = class extends Connector {
195
195
  try {
196
196
  const provider = await this.getProvider();
197
197
  if (!provider)
198
- throw new ConnectorNotFoundError();
198
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
199
199
  if (provider.on) {
200
200
  provider.on("accountsChanged", this.onAccountsChanged);
201
201
  provider.on("chainChanged", this.onChainChanged);
@@ -205,7 +205,7 @@ var InjectedConnector = class extends Connector {
205
205
  const accounts = await provider.request({
206
206
  method: "eth_requestAccounts"
207
207
  });
208
- const account = getAddress(accounts[0]);
208
+ const account = _viem.getAddress.call(void 0, accounts[0]);
209
209
  let id = await this.getChainId();
210
210
  let unsupported = this.isChainUnsupported(id);
211
211
  if (chainId && id !== chainId) {
@@ -214,46 +214,46 @@ var InjectedConnector = class extends Connector {
214
214
  unsupported = this.isChainUnsupported(id);
215
215
  }
216
216
  if (this.options.shimDisconnect)
217
- this.storage?.setItem(this.shimDisconnectKey, true);
217
+ _optionalChain([this, 'access', _7 => _7.storage, 'optionalAccess', _8 => _8.setItem, 'call', _9 => _9(this.shimDisconnectKey, true)]);
218
218
  return { account, chain: { id, unsupported } };
219
219
  } catch (error) {
220
220
  if (this.isUserRejectedRequestError(error))
221
- throw new UserRejectedRequestError(error);
221
+ throw new (0, _viem.UserRejectedRequestError)(error);
222
222
  if (error.code === -32002)
223
- throw new ResourceNotFoundRpcError(error);
223
+ throw new (0, _viem.ResourceNotFoundRpcError)(error);
224
224
  throw error;
225
225
  }
226
226
  }
227
227
  async disconnect() {
228
228
  const provider = await this.getProvider();
229
- if (!provider?.removeListener)
229
+ if (!_optionalChain([provider, 'optionalAccess', _10 => _10.removeListener]))
230
230
  return;
231
231
  provider.removeListener("accountsChanged", this.onAccountsChanged);
232
232
  provider.removeListener("chainChanged", this.onChainChanged);
233
233
  provider.removeListener("disconnect", this.onDisconnect);
234
234
  if (this.options.shimDisconnect)
235
- this.storage?.removeItem(this.shimDisconnectKey);
235
+ _optionalChain([this, 'access', _11 => _11.storage, 'optionalAccess', _12 => _12.removeItem, 'call', _13 => _13(this.shimDisconnectKey)]);
236
236
  }
237
237
  async getAccount() {
238
238
  const provider = await this.getProvider();
239
239
  if (!provider)
240
- throw new ConnectorNotFoundError();
240
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
241
241
  const accounts = await provider.request({
242
242
  method: "eth_accounts"
243
243
  });
244
- return getAddress(accounts[0]);
244
+ return _viem.getAddress.call(void 0, accounts[0]);
245
245
  }
246
246
  async getChainId() {
247
247
  const provider = await this.getProvider();
248
248
  if (!provider)
249
- throw new ConnectorNotFoundError();
250
- return provider.request({ method: "eth_chainId" }).then(normalizeChainId);
249
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
250
+ return provider.request({ method: "eth_chainId" }).then(_chunkOQILYQDOjs.normalizeChainId);
251
251
  }
252
252
  async getProvider() {
253
253
  const provider = this.options.getProvider();
254
254
  if (provider)
255
- __privateSet(this, _provider, provider);
256
- return __privateGet(this, _provider);
255
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, provider);
256
+ return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
257
257
  }
258
258
  async getWalletClient({ chainId } = {}) {
259
259
  const [provider, account] = await Promise.all([
@@ -263,30 +263,30 @@ var InjectedConnector = class extends Connector {
263
263
  const chain = this.chains.find((x) => x.id === chainId);
264
264
  if (!provider)
265
265
  throw new Error("provider is required.");
266
- return createWalletClient({
266
+ return _viem.createWalletClient.call(void 0, {
267
267
  account,
268
268
  chain,
269
- transport: custom(provider)
269
+ transport: _viem.custom.call(void 0, provider)
270
270
  });
271
271
  }
272
272
  async isAuthorized() {
273
273
  try {
274
- if (this.options.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey))
274
+ if (this.options.shimDisconnect && !_optionalChain([this, 'access', _14 => _14.storage, 'optionalAccess', _15 => _15.getItem, 'call', _16 => _16(this.shimDisconnectKey)]))
275
275
  return false;
276
276
  const provider = await this.getProvider();
277
277
  if (!provider)
278
- throw new ConnectorNotFoundError();
278
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
279
279
  const account = await this.getAccount();
280
280
  return !!account;
281
- } catch {
281
+ } catch (e) {
282
282
  return false;
283
283
  }
284
284
  }
285
285
  async switchChain(chainId) {
286
286
  const provider = await this.getProvider();
287
287
  if (!provider)
288
- throw new ConnectorNotFoundError();
289
- const id = numberToHex(chainId);
288
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
289
+ const id = _viem.numberToHex.call(void 0, chainId);
290
290
  try {
291
291
  await Promise.all([
292
292
  provider.request({
@@ -295,26 +295,26 @@ var InjectedConnector = class extends Connector {
295
295
  }),
296
296
  new Promise(
297
297
  (res) => this.on("change", ({ chain }) => {
298
- if (chain?.id === chainId)
298
+ if (_optionalChain([chain, 'optionalAccess', _17 => _17.id]) === chainId)
299
299
  res();
300
300
  })
301
301
  )
302
302
  ]);
303
- return this.chains.find((x) => x.id === chainId) ?? {
303
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
304
304
  id: chainId,
305
305
  name: `Chain ${id}`,
306
306
  network: `${id}`,
307
307
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
308
308
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
309
- };
309
+ }));
310
310
  } catch (error) {
311
311
  const chain = this.chains.find((x) => x.id === chainId);
312
312
  if (!chain)
313
- throw new ChainNotConfiguredForConnectorError({
313
+ throw new (0, _chunkZCAPXGBXjs.ChainNotConfiguredForConnectorError)({
314
314
  chainId,
315
315
  connectorId: this.id
316
316
  });
317
- if (error.code === 4902 || error?.data?.originalError?.code === 4902) {
317
+ if (error.code === 4902 || _optionalChain([error, 'optionalAccess', _18 => _18.data, 'optionalAccess', _19 => _19.originalError, 'optionalAccess', _20 => _20.code]) === 4902) {
318
318
  try {
319
319
  await provider.request({
320
320
  method: "wallet_addEthereumChain",
@@ -323,24 +323,24 @@ var InjectedConnector = class extends Connector {
323
323
  chainId: id,
324
324
  chainName: chain.name,
325
325
  nativeCurrency: chain.nativeCurrency,
326
- rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
326
+ rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _21 => _21.rpcUrls, 'access', _22 => _22.public, 'optionalAccess', _23 => _23.http, 'access', _24 => _24[0]]), () => ( ""))],
327
327
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
328
328
  }
329
329
  ]
330
330
  });
331
331
  const currentChainId = await this.getChainId();
332
332
  if (currentChainId !== chainId)
333
- throw new UserRejectedRequestError(
333
+ throw new (0, _viem.UserRejectedRequestError)(
334
334
  new Error("User rejected switch after adding network.")
335
335
  );
336
336
  return chain;
337
337
  } catch (error2) {
338
- throw new UserRejectedRequestError(error2);
338
+ throw new (0, _viem.UserRejectedRequestError)(error2);
339
339
  }
340
340
  }
341
341
  if (this.isUserRejectedRequestError(error))
342
- throw new UserRejectedRequestError(error);
343
- throw new SwitchChainError(error);
342
+ throw new (0, _viem.UserRejectedRequestError)(error);
343
+ throw new (0, _viem.SwitchChainError)(error);
344
344
  }
345
345
  }
346
346
  async watchAsset({
@@ -351,7 +351,7 @@ var InjectedConnector = class extends Connector {
351
351
  }) {
352
352
  const provider = await this.getProvider();
353
353
  if (!provider)
354
- throw new ConnectorNotFoundError();
354
+ throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
355
355
  return provider.request({
356
356
  method: "wallet_watchAsset",
357
357
  params: {
@@ -371,6 +371,6 @@ var InjectedConnector = class extends Connector {
371
371
  };
372
372
  _provider = new WeakMap();
373
373
 
374
- export {
375
- InjectedConnector
376
- };
374
+
375
+
376
+ exports.InjectedConnector = InjectedConnector;
@@ -1,4 +1,4 @@
1
- // src/utils/normalizeChainId.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/normalizeChainId.ts
2
2
  function normalizeChainId(chainId) {
3
3
  if (typeof chainId === "string")
4
4
  return Number.parseInt(
@@ -10,6 +10,6 @@ function normalizeChainId(chainId) {
10
10
  return chainId;
11
11
  }
12
12
 
13
- export {
14
- normalizeChainId
15
- };
13
+
14
+
15
+ exports.normalizeChainId = normalizeChainId;
@@ -1,4 +1,4 @@
1
- var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -28,11 +28,11 @@ var __privateMethod = (obj, member, method) => {
28
28
  };
29
29
 
30
30
  // src/base.ts
31
- import { default as EventEmitter } from "eventemitter3";
32
- import { goerli, mainnet } from "viem/chains";
33
- var Connector = class extends EventEmitter {
31
+ var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);
32
+ var _chains = require('viem/chains');
33
+ var Connector = class extends _eventemitter32.default {
34
34
  constructor({
35
- chains = [mainnet, goerli],
35
+ chains = [_chains.mainnet, _chains.goerli],
36
36
  options
37
37
  }) {
38
38
  super();
@@ -43,7 +43,7 @@ var Connector = class extends EventEmitter {
43
43
  this.options = options;
44
44
  }
45
45
  getBlockExplorerUrls(chain) {
46
- const { default: blockExplorer, ...blockExplorers } = chain.blockExplorers ?? {};
46
+ const { default: blockExplorer, ...blockExplorers } = _nullishCoalesce(chain.blockExplorers, () => ( {}));
47
47
  if (blockExplorer)
48
48
  return [
49
49
  blockExplorer.url,
@@ -58,11 +58,11 @@ var Connector = class extends EventEmitter {
58
58
  }
59
59
  };
60
60
 
61
- export {
62
- __publicField,
63
- __privateGet,
64
- __privateAdd,
65
- __privateSet,
66
- __privateMethod,
67
- Connector
68
- };
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+ exports.__publicField = __publicField; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod; exports.Connector = Connector;
@@ -1,6 +1,6 @@
1
- import {
2
- __publicField
3
- } from "./chunk-QYMCVNHT.js";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
4
4
 
5
5
  // src/errors.ts
6
6
  var ChainNotConfiguredForConnectorError = class extends Error {
@@ -9,18 +9,18 @@ var ChainNotConfiguredForConnectorError = class extends Error {
9
9
  connectorId
10
10
  }) {
11
11
  super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
12
- __publicField(this, "name", "ChainNotConfiguredForConnectorError");
12
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "ChainNotConfiguredForConnectorError");
13
13
  }
14
14
  };
15
15
  var ConnectorNotFoundError = class extends Error {
16
16
  constructor() {
17
17
  super(...arguments);
18
- __publicField(this, "name", "ConnectorNotFoundError");
19
- __publicField(this, "message", "Connector not found");
18
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "ConnectorNotFoundError");
19
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "message", "Connector not found");
20
20
  }
21
21
  };
22
22
 
23
- export {
24
- ChainNotConfiguredForConnectorError,
25
- ConnectorNotFoundError
26
- };
23
+
24
+
25
+
26
+ exports.ChainNotConfiguredForConnectorError = ChainNotConfiguredForConnectorError; exports.ConnectorNotFoundError = ConnectorNotFoundError;
@@ -1,28 +1,28 @@
1
- import {
2
- ChainNotConfiguredForConnectorError
3
- } from "./chunk-ZCAPXGBX.js";
4
- import {
5
- normalizeChainId
6
- } from "./chunk-OQILYQDO.js";
7
- import {
8
- Connector,
9
- __privateAdd,
10
- __privateGet,
11
- __privateSet,
12
- __publicField
13
- } from "./chunk-QYMCVNHT.js";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _chunkZCAPXGBXjs = require('./chunk-ZCAPXGBX.js');
4
+
5
+
6
+ var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
14
14
 
15
15
  // src/coinbaseWallet.ts
16
- import {
17
- SwitchChainError,
18
- UserRejectedRequestError,
19
- createWalletClient,
20
- custom,
21
- getAddress,
22
- numberToHex
23
- } from "viem";
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ var _viem = require('viem');
24
24
  var _client, _provider;
25
- var CoinbaseWalletConnector = class extends Connector {
25
+ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
26
26
  constructor({ chains, options }) {
27
27
  super({
28
28
  chains,
@@ -31,23 +31,23 @@ var CoinbaseWalletConnector = class extends Connector {
31
31
  ...options
32
32
  }
33
33
  });
34
- __publicField(this, "id", "coinbaseWallet");
35
- __publicField(this, "name", "Coinbase Wallet");
36
- __publicField(this, "ready", true);
37
- __privateAdd(this, _client, void 0);
38
- __privateAdd(this, _provider, void 0);
39
- __publicField(this, "onAccountsChanged", (accounts) => {
34
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "coinbaseWallet");
35
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "Coinbase Wallet");
36
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "ready", true);
37
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _client, void 0);
38
+ _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _provider, void 0);
39
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
40
40
  if (accounts.length === 0)
41
41
  this.emit("disconnect");
42
42
  else
43
- this.emit("change", { account: getAddress(accounts[0]) });
43
+ this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
44
44
  });
45
- __publicField(this, "onChainChanged", (chainId) => {
46
- const id = normalizeChainId(chainId);
45
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
46
+ const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
47
47
  const unsupported = this.isChainUnsupported(id);
48
48
  this.emit("change", { chain: { id, unsupported } });
49
49
  });
50
- __publicField(this, "onDisconnect", () => {
50
+ _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
51
51
  this.emit("disconnect");
52
52
  });
53
53
  }
@@ -59,7 +59,7 @@ var CoinbaseWalletConnector = class extends Connector {
59
59
  provider.on("disconnect", this.onDisconnect);
60
60
  this.emit("message", { type: "connecting" });
61
61
  const accounts = await provider.enable();
62
- const account = getAddress(accounts[0]);
62
+ const account = _viem.getAddress.call(void 0, accounts[0]);
63
63
  let id = await this.getChainId();
64
64
  let unsupported = this.isChainUnsupported(id);
65
65
  if (chainId && id !== chainId) {
@@ -75,12 +75,12 @@ var CoinbaseWalletConnector = class extends Connector {
75
75
  if (/(user closed modal|accounts received is empty)/i.test(
76
76
  error.message
77
77
  ))
78
- throw new UserRejectedRequestError(error);
78
+ throw new (0, _viem.UserRejectedRequestError)(error);
79
79
  throw error;
80
80
  }
81
81
  }
82
82
  async disconnect() {
83
- if (!__privateGet(this, _provider))
83
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
84
84
  return;
85
85
  const provider = await this.getProvider();
86
86
  provider.removeListener("accountsChanged", this.onAccountsChanged);
@@ -94,32 +94,32 @@ var CoinbaseWalletConnector = class extends Connector {
94
94
  const accounts = await provider.request({
95
95
  method: "eth_accounts"
96
96
  });
97
- return getAddress(accounts[0]);
97
+ return _viem.getAddress.call(void 0, accounts[0]);
98
98
  }
99
99
  async getChainId() {
100
100
  const provider = await this.getProvider();
101
- const chainId = normalizeChainId(provider.chainId);
101
+ const chainId = _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
102
102
  return chainId;
103
103
  }
104
104
  async getProvider() {
105
- if (!__privateGet(this, _provider)) {
106
- let CoinbaseWalletSDK = (await import("@coinbase/wallet-sdk")).default;
105
+ if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider)) {
106
+ let CoinbaseWalletSDK = (await Promise.resolve().then(() => require("@coinbase/wallet-sdk"))).default;
107
107
  if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function")
108
108
  CoinbaseWalletSDK = CoinbaseWalletSDK.default;
109
- __privateSet(this, _client, new CoinbaseWalletSDK(this.options));
109
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _client, new CoinbaseWalletSDK(this.options));
110
110
  class WalletProvider {
111
111
  }
112
112
  class Client {
113
113
  }
114
- const walletExtensionChainId = __privateGet(this, _client).walletExtension?.getChainId();
114
+ const walletExtensionChainId = _optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _client), 'access', _ => _.walletExtension, 'optionalAccess', _2 => _2.getChainId, 'call', _3 => _3()]);
115
115
  const chain = this.chains.find(
116
116
  (chain2) => this.options.chainId ? chain2.id === this.options.chainId : chain2.id === walletExtensionChainId
117
117
  ) || this.chains[0];
118
- const chainId = this.options.chainId || chain?.id;
119
- const jsonRpcUrl = this.options.jsonRpcUrl || chain?.rpcUrls.default.http[0];
120
- __privateSet(this, _provider, __privateGet(this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
118
+ const chainId = this.options.chainId || _optionalChain([chain, 'optionalAccess', _4 => _4.id]);
119
+ const jsonRpcUrl = this.options.jsonRpcUrl || _optionalChain([chain, 'optionalAccess', _5 => _5.rpcUrls, 'access', _6 => _6.default, 'access', _7 => _7.http, 'access', _8 => _8[0]]);
120
+ _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
121
121
  }
122
- return __privateGet(this, _provider);
122
+ return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
123
123
  }
124
124
  async getWalletClient({ chainId } = {}) {
125
125
  const [provider, account] = await Promise.all([
@@ -129,39 +129,39 @@ var CoinbaseWalletConnector = class extends Connector {
129
129
  const chain = this.chains.find((x) => x.id === chainId);
130
130
  if (!provider)
131
131
  throw new Error("provider is required.");
132
- return createWalletClient({
132
+ return _viem.createWalletClient.call(void 0, {
133
133
  account,
134
134
  chain,
135
- transport: custom(provider)
135
+ transport: _viem.custom.call(void 0, provider)
136
136
  });
137
137
  }
138
138
  async isAuthorized() {
139
139
  try {
140
140
  const account = await this.getAccount();
141
141
  return !!account;
142
- } catch {
142
+ } catch (e) {
143
143
  return false;
144
144
  }
145
145
  }
146
146
  async switchChain(chainId) {
147
147
  const provider = await this.getProvider();
148
- const id = numberToHex(chainId);
148
+ const id = _viem.numberToHex.call(void 0, chainId);
149
149
  try {
150
150
  await provider.request({
151
151
  method: "wallet_switchEthereumChain",
152
152
  params: [{ chainId: id }]
153
153
  });
154
- return this.chains.find((x) => x.id === chainId) ?? {
154
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
155
155
  id: chainId,
156
156
  name: `Chain ${id}`,
157
157
  network: `${id}`,
158
158
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
159
159
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
160
- };
160
+ }));
161
161
  } catch (error) {
162
162
  const chain = this.chains.find((x) => x.id === chainId);
163
163
  if (!chain)
164
- throw new ChainNotConfiguredForConnectorError({
164
+ throw new (0, _chunkZCAPXGBXjs.ChainNotConfiguredForConnectorError)({
165
165
  chainId,
166
166
  connectorId: this.id
167
167
  });
@@ -174,17 +174,17 @@ var CoinbaseWalletConnector = class extends Connector {
174
174
  chainId: id,
175
175
  chainName: chain.name,
176
176
  nativeCurrency: chain.nativeCurrency,
177
- rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
177
+ rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( ""))],
178
178
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
179
179
  }
180
180
  ]
181
181
  });
182
182
  return chain;
183
183
  } catch (error2) {
184
- throw new UserRejectedRequestError(error2);
184
+ throw new (0, _viem.UserRejectedRequestError)(error2);
185
185
  }
186
186
  }
187
- throw new SwitchChainError(error);
187
+ throw new (0, _viem.SwitchChainError)(error);
188
188
  }
189
189
  }
190
190
  async watchAsset({
@@ -210,6 +210,6 @@ var CoinbaseWalletConnector = class extends Connector {
210
210
  };
211
211
  _client = new WeakMap();
212
212
  _provider = new WeakMap();
213
- export {
214
- CoinbaseWalletConnector
215
- };
213
+
214
+
215
+ exports.CoinbaseWalletConnector = CoinbaseWalletConnector;