@wagmi/connectors 0.3.12 → 0.3.13-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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 wagmi
3
+ Copyright (c) 2022–PRESENT weth, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/coinbaseWallet.mjs",
3
3
  "main": "../dist/coinbaseWallet.js"
4
4
  }
@@ -1,25 +1,25 @@
1
- import {
2
- Connector,
3
- __privateAdd,
4
- __privateGet,
5
- __privateSet,
6
- __publicField
7
- } from "./chunk-5NCTPR6C.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
+
5
+
6
+
7
+ var _chunk5NCTPR6Cjs = require('./chunk-5NCTPR6C.js');
8
8
 
9
9
  // src/injected.ts
10
- import {
11
- AddChainError,
12
- ChainNotConfiguredError,
13
- ConnectorNotFoundError,
14
- ProviderRpcError,
15
- ResourceUnavailableError,
16
- SwitchChainError,
17
- UserRejectedRequestError,
18
- getClient,
19
- normalizeChainId
20
- } from "@wagmi/core";
21
- import { providers } from "ethers";
22
- import { getAddress, hexValue } from "ethers/lib/utils.js";
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ var _core = require('@wagmi/core');
21
+ var _ethers = require('ethers');
22
+ var _utilsjs = require('ethers/lib/utils.js');
23
23
 
24
24
  // src/utils/getInjectedName.ts
25
25
  function getInjectedName(ethereum) {
@@ -89,7 +89,7 @@ function getInjectedName(ethereum) {
89
89
  if (provider.isMetaMask)
90
90
  return "MetaMask";
91
91
  };
92
- if (ethereum.providers?.length) {
92
+ if (_optionalChain([ethereum, 'access', _ => _.providers, 'optionalAccess', _2 => _2.length])) {
93
93
  const nameSet = /* @__PURE__ */ new Set();
94
94
  let unknownCount = 1;
95
95
  for (const provider of ethereum.providers) {
@@ -103,14 +103,14 @@ function getInjectedName(ethereum) {
103
103
  const names = [...nameSet];
104
104
  if (names.length)
105
105
  return names;
106
- return names[0] ?? "Injected";
106
+ return _nullishCoalesce(names[0], () => ( "Injected"));
107
107
  }
108
- return getName(ethereum) ?? "Injected";
108
+ return _nullishCoalesce(getName(ethereum), () => ( "Injected"));
109
109
  }
110
110
 
111
111
  // src/injected.ts
112
112
  var _provider;
113
- var InjectedConnector = class extends Connector {
113
+ var InjectedConnector = class extends _chunk5NCTPR6Cjs.Connector {
114
114
  constructor({
115
115
  chains,
116
116
  options: options_
@@ -121,25 +121,25 @@ var InjectedConnector = class extends Connector {
121
121
  ...options_
122
122
  };
123
123
  super({ chains, options });
124
- __publicField(this, "id", "injected");
125
- __publicField(this, "name");
126
- __publicField(this, "ready");
127
- __privateAdd(this, _provider, void 0);
128
- __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
129
- __publicField(this, "onAccountsChanged", (accounts) => {
124
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "injected");
125
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name");
126
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready");
127
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
128
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
129
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
130
130
  if (accounts.length === 0)
131
131
  this.emit("disconnect");
132
132
  else
133
133
  this.emit("change", {
134
- account: getAddress(accounts[0])
134
+ account: _utilsjs.getAddress.call(void 0, accounts[0])
135
135
  });
136
136
  });
137
- __publicField(this, "onChainChanged", (chainId) => {
138
- const id = normalizeChainId(chainId);
137
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
138
+ const id = _core.normalizeChainId.call(void 0, chainId);
139
139
  const unsupported = this.isChainUnsupported(id);
140
140
  this.emit("change", { chain: { id, unsupported } });
141
141
  });
142
- __publicField(this, "onDisconnect", async (error) => {
142
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", async (error) => {
143
143
  if (error.code === 1013) {
144
144
  const provider = await this.getProvider();
145
145
  if (provider) {
@@ -150,7 +150,7 @@ var InjectedConnector = class extends Connector {
150
150
  }
151
151
  this.emit("disconnect");
152
152
  if (this.options.shimDisconnect)
153
- getClient().storage?.removeItem(this.shimDisconnectKey);
153
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _3 => _3.storage, 'optionalAccess', _4 => _4.removeItem, 'call', _5 => _5(this.shimDisconnectKey)]);
154
154
  });
155
155
  const provider = options.getProvider();
156
156
  if (typeof options.name === "string")
@@ -173,7 +173,7 @@ var InjectedConnector = class extends Connector {
173
173
  try {
174
174
  const provider = await this.getProvider();
175
175
  if (!provider)
176
- throw new ConnectorNotFoundError();
176
+ throw new (0, _core.ConnectorNotFoundError)();
177
177
  if (provider.on) {
178
178
  provider.on("accountsChanged", this.onAccountsChanged);
179
179
  provider.on("chainChanged", this.onChainChanged);
@@ -183,7 +183,7 @@ var InjectedConnector = class extends Connector {
183
183
  const accounts = await provider.request({
184
184
  method: "eth_requestAccounts"
185
185
  });
186
- const account = getAddress(accounts[0]);
186
+ const account = _utilsjs.getAddress.call(void 0, accounts[0]);
187
187
  let id = await this.getChainId();
188
188
  let unsupported = this.isChainUnsupported(id);
189
189
  if (chainId && id !== chainId) {
@@ -192,75 +192,75 @@ var InjectedConnector = class extends Connector {
192
192
  unsupported = this.isChainUnsupported(id);
193
193
  }
194
194
  if (this.options.shimDisconnect)
195
- getClient().storage?.setItem(this.shimDisconnectKey, true);
195
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.setItem, 'call', _8 => _8(this.shimDisconnectKey, true)]);
196
196
  return { account, chain: { id, unsupported }, provider };
197
197
  } catch (error) {
198
198
  if (this.isUserRejectedRequestError(error))
199
- throw new UserRejectedRequestError(error);
199
+ throw new (0, _core.UserRejectedRequestError)(error);
200
200
  if (error.code === -32002)
201
- throw new ResourceUnavailableError(error);
201
+ throw new (0, _core.ResourceUnavailableError)(error);
202
202
  throw error;
203
203
  }
204
204
  }
205
205
  async disconnect() {
206
206
  const provider = await this.getProvider();
207
- if (!provider?.removeListener)
207
+ if (!_optionalChain([provider, 'optionalAccess', _9 => _9.removeListener]))
208
208
  return;
209
209
  provider.removeListener("accountsChanged", this.onAccountsChanged);
210
210
  provider.removeListener("chainChanged", this.onChainChanged);
211
211
  provider.removeListener("disconnect", this.onDisconnect);
212
212
  if (this.options.shimDisconnect)
213
- getClient().storage?.removeItem(this.shimDisconnectKey);
213
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _10 => _10.storage, 'optionalAccess', _11 => _11.removeItem, 'call', _12 => _12(this.shimDisconnectKey)]);
214
214
  }
215
215
  async getAccount() {
216
216
  const provider = await this.getProvider();
217
217
  if (!provider)
218
- throw new ConnectorNotFoundError();
218
+ throw new (0, _core.ConnectorNotFoundError)();
219
219
  const accounts = await provider.request({
220
220
  method: "eth_accounts"
221
221
  });
222
- return getAddress(accounts[0]);
222
+ return _utilsjs.getAddress.call(void 0, accounts[0]);
223
223
  }
224
224
  async getChainId() {
225
225
  const provider = await this.getProvider();
226
226
  if (!provider)
227
- throw new ConnectorNotFoundError();
228
- return provider.request({ method: "eth_chainId" }).then(normalizeChainId);
227
+ throw new (0, _core.ConnectorNotFoundError)();
228
+ return provider.request({ method: "eth_chainId" }).then(_core.normalizeChainId);
229
229
  }
230
230
  async getProvider() {
231
231
  const provider = this.options.getProvider();
232
232
  if (provider)
233
- __privateSet(this, _provider, provider);
234
- return __privateGet(this, _provider);
233
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, provider);
234
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
235
235
  }
236
236
  async getSigner({ chainId } = {}) {
237
237
  const [provider, account] = await Promise.all([
238
238
  this.getProvider(),
239
239
  this.getAccount()
240
240
  ]);
241
- return new providers.Web3Provider(
241
+ return new _ethers.providers.Web3Provider(
242
242
  provider,
243
243
  chainId
244
244
  ).getSigner(account);
245
245
  }
246
246
  async isAuthorized() {
247
247
  try {
248
- if (this.options.shimDisconnect && !getClient().storage?.getItem(this.shimDisconnectKey))
248
+ if (this.options.shimDisconnect && !_optionalChain([_core.getClient.call(void 0, ), 'access', _13 => _13.storage, 'optionalAccess', _14 => _14.getItem, 'call', _15 => _15(this.shimDisconnectKey)]))
249
249
  return false;
250
250
  const provider = await this.getProvider();
251
251
  if (!provider)
252
- throw new ConnectorNotFoundError();
252
+ throw new (0, _core.ConnectorNotFoundError)();
253
253
  const account = await this.getAccount();
254
254
  return !!account;
255
- } catch {
255
+ } catch (e) {
256
256
  return false;
257
257
  }
258
258
  }
259
259
  async switchChain(chainId) {
260
260
  const provider = await this.getProvider();
261
261
  if (!provider)
262
- throw new ConnectorNotFoundError();
263
- const id = hexValue(chainId);
262
+ throw new (0, _core.ConnectorNotFoundError)();
263
+ const id = _utilsjs.hexValue.call(void 0, chainId);
264
264
  try {
265
265
  await Promise.all([
266
266
  provider.request({
@@ -269,23 +269,23 @@ var InjectedConnector = class extends Connector {
269
269
  }),
270
270
  new Promise(
271
271
  (res) => this.on("change", ({ chain }) => {
272
- if (chain?.id === chainId)
272
+ if (_optionalChain([chain, 'optionalAccess', _16 => _16.id]) === chainId)
273
273
  res();
274
274
  })
275
275
  )
276
276
  ]);
277
- return this.chains.find((x) => x.id === chainId) ?? {
277
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
278
278
  id: chainId,
279
279
  name: `Chain ${id}`,
280
280
  network: `${id}`,
281
281
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
282
282
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
283
- };
283
+ }));
284
284
  } catch (error) {
285
285
  const chain = this.chains.find((x) => x.id === chainId);
286
286
  if (!chain)
287
- throw new ChainNotConfiguredError({ chainId, connectorId: this.id });
288
- if (error.code === 4902 || error?.data?.originalError?.code === 4902) {
287
+ throw new (0, _core.ChainNotConfiguredError)({ chainId, connectorId: this.id });
288
+ if (error.code === 4902 || _optionalChain([error, 'optionalAccess', _17 => _17.data, 'optionalAccess', _18 => _18.originalError, 'optionalAccess', _19 => _19.code]) === 4902) {
289
289
  try {
290
290
  await provider.request({
291
291
  method: "wallet_addEthereumChain",
@@ -294,27 +294,27 @@ var InjectedConnector = class extends Connector {
294
294
  chainId: id,
295
295
  chainName: chain.name,
296
296
  nativeCurrency: chain.nativeCurrency,
297
- rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
297
+ rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _20 => _20.rpcUrls, 'access', _21 => _21.public, 'optionalAccess', _22 => _22.http, 'access', _23 => _23[0]]), () => ( ""))],
298
298
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
299
299
  }
300
300
  ]
301
301
  });
302
302
  const currentChainId = await this.getChainId();
303
303
  if (currentChainId !== chainId)
304
- throw new ProviderRpcError(
304
+ throw new (0, _core.ProviderRpcError)(
305
305
  "User rejected switch after adding network.",
306
306
  { code: 4001 }
307
307
  );
308
308
  return chain;
309
309
  } catch (addError) {
310
310
  if (this.isUserRejectedRequestError(addError))
311
- throw new UserRejectedRequestError(addError);
312
- throw new AddChainError();
311
+ throw new (0, _core.UserRejectedRequestError)(addError);
312
+ throw new (0, _core.AddChainError)();
313
313
  }
314
314
  }
315
315
  if (this.isUserRejectedRequestError(error))
316
- throw new UserRejectedRequestError(error);
317
- throw new SwitchChainError(error);
316
+ throw new (0, _core.UserRejectedRequestError)(error);
317
+ throw new (0, _core.SwitchChainError)(error);
318
318
  }
319
319
  }
320
320
  async watchAsset({
@@ -325,7 +325,7 @@ var InjectedConnector = class extends Connector {
325
325
  }) {
326
326
  const provider = await this.getProvider();
327
327
  if (!provider)
328
- throw new ConnectorNotFoundError();
328
+ throw new (0, _core.ConnectorNotFoundError)();
329
329
  return provider.request({
330
330
  method: "wallet_watchAsset",
331
331
  params: {
@@ -345,6 +345,6 @@ var InjectedConnector = class extends Connector {
345
345
  };
346
346
  _provider = new WeakMap();
347
347
 
348
- export {
349
- InjectedConnector
350
- };
348
+
349
+
350
+ exports.InjectedConnector = InjectedConnector;
@@ -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 { goerli, mainnet } from "@wagmi/core/chains";
32
- import { default as EventEmitter } from "eventemitter3";
33
- var Connector = class extends EventEmitter {
31
+ var _chains = require('@wagmi/core/chains');
32
+ var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);
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();
@@ -42,7 +42,7 @@ var Connector = class extends EventEmitter {
42
42
  this.options = options;
43
43
  }
44
44
  getBlockExplorerUrls(chain) {
45
- const { default: blockExplorer, ...blockExplorers } = chain.blockExplorers ?? {};
45
+ const { default: blockExplorer, ...blockExplorers } = _nullishCoalesce(chain.blockExplorers, () => ( {}));
46
46
  if (blockExplorer)
47
47
  return [
48
48
  blockExplorer.url,
@@ -54,11 +54,11 @@ var Connector = class extends EventEmitter {
54
54
  }
55
55
  };
56
56
 
57
- export {
58
- __publicField,
59
- __privateGet,
60
- __privateAdd,
61
- __privateSet,
62
- __privateMethod,
63
- Connector
64
- };
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ exports.__publicField = __publicField; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod; exports.Connector = Connector;
@@ -1,24 +1,24 @@
1
- import {
2
- Connector,
3
- __privateAdd,
4
- __privateGet,
5
- __privateMethod,
6
- __privateSet,
7
- __publicField
8
- } from "./chunk-5NCTPR6C.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
+
5
+
6
+
7
+
8
+ var _chunk5NCTPR6Cjs = require('./chunk-5NCTPR6C.js');
9
9
 
10
10
  // src/coinbaseWallet.ts
11
- import {
12
- AddChainError,
13
- ChainNotConfiguredError,
14
- SwitchChainError,
15
- UserRejectedRequestError,
16
- normalizeChainId
17
- } from "@wagmi/core";
18
- import { providers } from "ethers";
19
- import { getAddress, hexValue } from "ethers/lib/utils.js";
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _core = require('@wagmi/core');
18
+ var _ethers = require('ethers');
19
+ var _utilsjs = require('ethers/lib/utils.js');
20
20
  var _client, _provider, _isUserRejectedRequestError, isUserRejectedRequestError_fn;
21
- var CoinbaseWalletConnector = class extends Connector {
21
+ var CoinbaseWalletConnector = class extends _chunk5NCTPR6Cjs.Connector {
22
22
  constructor({ chains, options }) {
23
23
  super({
24
24
  chains,
@@ -27,24 +27,24 @@ var CoinbaseWalletConnector = class extends Connector {
27
27
  ...options
28
28
  }
29
29
  });
30
- __privateAdd(this, _isUserRejectedRequestError);
31
- __publicField(this, "id", "coinbaseWallet");
32
- __publicField(this, "name", "Coinbase Wallet");
33
- __publicField(this, "ready", true);
34
- __privateAdd(this, _client, void 0);
35
- __privateAdd(this, _provider, void 0);
36
- __publicField(this, "onAccountsChanged", (accounts) => {
30
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _isUserRejectedRequestError);
31
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "coinbaseWallet");
32
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "Coinbase Wallet");
33
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", true);
34
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _client, void 0);
35
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
36
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
37
37
  if (accounts.length === 0)
38
38
  this.emit("disconnect");
39
39
  else
40
- this.emit("change", { account: getAddress(accounts[0]) });
40
+ this.emit("change", { account: _utilsjs.getAddress.call(void 0, accounts[0]) });
41
41
  });
42
- __publicField(this, "onChainChanged", (chainId) => {
43
- const id = normalizeChainId(chainId);
42
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
43
+ const id = _core.normalizeChainId.call(void 0, chainId);
44
44
  const unsupported = this.isChainUnsupported(id);
45
45
  this.emit("change", { chain: { id, unsupported } });
46
46
  });
47
- __publicField(this, "onDisconnect", () => {
47
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", () => {
48
48
  this.emit("disconnect");
49
49
  });
50
50
  }
@@ -56,7 +56,7 @@ var CoinbaseWalletConnector = class extends Connector {
56
56
  provider.on("disconnect", this.onDisconnect);
57
57
  this.emit("message", { type: "connecting" });
58
58
  const accounts = await provider.enable();
59
- const account = getAddress(accounts[0]);
59
+ const account = _utilsjs.getAddress.call(void 0, accounts[0]);
60
60
  let id = await this.getChainId();
61
61
  let unsupported = this.isChainUnsupported(id);
62
62
  if (chainId && id !== chainId) {
@@ -67,7 +67,7 @@ var CoinbaseWalletConnector = class extends Connector {
67
67
  return {
68
68
  account,
69
69
  chain: { id, unsupported },
70
- provider: new providers.Web3Provider(
70
+ provider: new _ethers.providers.Web3Provider(
71
71
  provider
72
72
  )
73
73
  };
@@ -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, _core.UserRejectedRequestError)(error);
79
79
  throw error;
80
80
  }
81
81
  }
82
82
  async disconnect() {
83
- if (!__privateGet(this, _provider))
83
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
84
84
  return;
85
85
  const provider = await this.getProvider();
86
86
  provider.removeListener("accountsChanged", this.onAccountsChanged);
@@ -94,39 +94,39 @@ 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 _utilsjs.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 = _core.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 (!_chunk5NCTPR6Cjs.__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
+ _chunk5NCTPR6Cjs.__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([_chunk5NCTPR6Cjs.__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
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
121
121
  }
122
- return __privateGet(this, _provider);
122
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
123
123
  }
124
124
  async getSigner({ chainId } = {}) {
125
125
  const [provider, account] = await Promise.all([
126
126
  this.getProvider(),
127
127
  this.getAccount()
128
128
  ]);
129
- return new providers.Web3Provider(
129
+ return new _ethers.providers.Web3Provider(
130
130
  provider,
131
131
  chainId
132
132
  ).getSigner(account);
@@ -135,29 +135,29 @@ var CoinbaseWalletConnector = class extends Connector {
135
135
  try {
136
136
  const account = await this.getAccount();
137
137
  return !!account;
138
- } catch {
138
+ } catch (e) {
139
139
  return false;
140
140
  }
141
141
  }
142
142
  async switchChain(chainId) {
143
143
  const provider = await this.getProvider();
144
- const id = hexValue(chainId);
144
+ const id = _utilsjs.hexValue.call(void 0, chainId);
145
145
  try {
146
146
  await provider.request({
147
147
  method: "wallet_switchEthereumChain",
148
148
  params: [{ chainId: id }]
149
149
  });
150
- return this.chains.find((x) => x.id === chainId) ?? {
150
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
151
151
  id: chainId,
152
152
  name: `Chain ${id}`,
153
153
  network: `${id}`,
154
154
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
155
155
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
156
- };
156
+ }));
157
157
  } catch (error) {
158
158
  const chain = this.chains.find((x) => x.id === chainId);
159
159
  if (!chain)
160
- throw new ChainNotConfiguredError({ chainId, connectorId: this.id });
160
+ throw new (0, _core.ChainNotConfiguredError)({ chainId, connectorId: this.id });
161
161
  if (error.code === 4902) {
162
162
  try {
163
163
  await provider.request({
@@ -167,21 +167,21 @@ var CoinbaseWalletConnector = class extends Connector {
167
167
  chainId: id,
168
168
  chainName: chain.name,
169
169
  nativeCurrency: chain.nativeCurrency,
170
- rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
170
+ rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( ""))],
171
171
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
172
172
  }
173
173
  ]
174
174
  });
175
175
  return chain;
176
176
  } catch (addError) {
177
- if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, addError))
178
- throw new UserRejectedRequestError(addError);
179
- throw new AddChainError();
177
+ if (_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, addError))
178
+ throw new (0, _core.UserRejectedRequestError)(addError);
179
+ throw new (0, _core.AddChainError)();
180
180
  }
181
181
  }
182
- if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, error))
183
- throw new UserRejectedRequestError(error);
184
- throw new SwitchChainError(error);
182
+ if (_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, error))
183
+ throw new (0, _core.UserRejectedRequestError)(error);
184
+ throw new (0, _core.SwitchChainError)(error);
185
185
  }
186
186
  }
187
187
  async watchAsset({
@@ -211,6 +211,6 @@ _isUserRejectedRequestError = new WeakSet();
211
211
  isUserRejectedRequestError_fn = function(error) {
212
212
  return /(user rejected)/i.test(error.message);
213
213
  };
214
- export {
215
- CoinbaseWalletConnector
216
- };
214
+
215
+
216
+ exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import {
2
- Connector
3
- } from "./chunk-5NCTPR6C.js";
4
- export {
5
- Connector
6
- };
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk5NCTPR6Cjs = require('./chunk-5NCTPR6C.js');
4
+
5
+
6
+ exports.Connector = _chunk5NCTPR6Cjs.Connector;
package/dist/injected.js CHANGED
@@ -1,7 +1,7 @@
1
- import {
2
- InjectedConnector
3
- } from "./chunk-4PFIHJ5Y.js";
4
- import "./chunk-5NCTPR6C.js";
5
- export {
6
- InjectedConnector
7
- };
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk4PFIHJ5Yjs = require('./chunk-4PFIHJ5Y.js');
4
+ require('./chunk-5NCTPR6C.js');
5
+
6
+
7
+ exports.InjectedConnector = _chunk4PFIHJ5Yjs.InjectedConnector;