@wagmi/connectors 0.1.3 → 0.1.4-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 awkweb.eth
3
+ Copyright (c) 2022 wagmi
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
@@ -2,7 +2,7 @@ import { Chain } from '@wagmi/core/chains';
2
2
  import { Address } from 'abitype';
3
3
  import EventEmitter from 'eventemitter3';
4
4
 
5
- type ConnectorData<Provider = any> = {
5
+ declare type ConnectorData<Provider = any> = {
6
6
  account?: Address;
7
7
  chain?: {
8
8
  id: number;
@@ -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
- __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
- ResourceUnavailableError,
15
- SwitchChainError,
16
- UserRejectedRequestError,
17
- getClient,
18
- normalizeChainId
19
- } from "@wagmi/core";
20
- import { providers } from "ethers";
21
- import { getAddress, hexValue } from "ethers/lib/utils.js";
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _core = require('@wagmi/core');
20
+ var _ethers = require('ethers');
21
+ var _utilsjs = require('ethers/lib/utils.js');
22
22
 
23
23
  // src/utils/getInjectedName.ts
24
24
  function getInjectedName(ethereum) {
@@ -58,7 +58,7 @@ function getInjectedName(ethereum) {
58
58
  if (provider.isMetaMask)
59
59
  return "MetaMask";
60
60
  };
61
- if (ethereum.providers?.length) {
61
+ if (_optionalChain([ethereum, 'access', _ => _.providers, 'optionalAccess', _2 => _2.length])) {
62
62
  const nameSet = /* @__PURE__ */ new Set();
63
63
  let unknownCount = 1;
64
64
  for (const provider of ethereum.providers) {
@@ -72,14 +72,14 @@ function getInjectedName(ethereum) {
72
72
  const names = [...nameSet];
73
73
  if (names.length)
74
74
  return names;
75
- return names[0] ?? "Injected";
75
+ return _nullishCoalesce(names[0], () => ( "Injected"));
76
76
  }
77
- return getName(ethereum) ?? "Injected";
77
+ return _nullishCoalesce(getName(ethereum), () => ( "Injected"));
78
78
  }
79
79
 
80
80
  // src/injected.ts
81
81
  var _provider, _switchingChains;
82
- var InjectedConnector = class extends Connector {
82
+ var InjectedConnector = class extends _chunk5NCTPR6Cjs.Connector {
83
83
  constructor({
84
84
  chains,
85
85
  options: options_
@@ -91,33 +91,33 @@ var InjectedConnector = class extends Connector {
91
91
  ...options_
92
92
  };
93
93
  super({ chains, options });
94
- __publicField(this, "id");
95
- __publicField(this, "name");
96
- __publicField(this, "ready");
97
- __privateAdd(this, _provider, void 0);
98
- __privateAdd(this, _switchingChains, void 0);
99
- __publicField(this, "shimDisconnectKey", "injected.shimDisconnect");
100
- __publicField(this, "onAccountsChanged", (accounts) => {
94
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id");
95
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name");
96
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready");
97
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
98
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _switchingChains, void 0);
99
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "shimDisconnectKey", "injected.shimDisconnect");
100
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
101
101
  if (accounts.length === 0)
102
102
  this.emit("disconnect");
103
103
  else
104
104
  this.emit("change", {
105
- account: getAddress(accounts[0])
105
+ account: _utilsjs.getAddress.call(void 0, accounts[0])
106
106
  });
107
107
  });
108
- __publicField(this, "onChainChanged", (chainId) => {
109
- const id = normalizeChainId(chainId);
108
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
109
+ const id = _core.normalizeChainId.call(void 0, chainId);
110
110
  const unsupported = this.isChainUnsupported(id);
111
111
  this.emit("change", { chain: { id, unsupported } });
112
112
  });
113
- __publicField(this, "onDisconnect", () => {
114
- if (this.options.shimChainChangedDisconnect && __privateGet(this, _switchingChains)) {
115
- __privateSet(this, _switchingChains, false);
113
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", () => {
114
+ if (this.options.shimChainChangedDisconnect && _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _switchingChains)) {
115
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _switchingChains, false);
116
116
  return;
117
117
  }
118
118
  this.emit("disconnect");
119
119
  if (this.options.shimDisconnect)
120
- getClient().storage?.removeItem(this.shimDisconnectKey);
120
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _3 => _3.storage, 'optionalAccess', _4 => _4.removeItem, 'call', _5 => _5(this.shimDisconnectKey)]);
121
121
  });
122
122
  const provider = options.getProvider();
123
123
  if (typeof options.name === "string")
@@ -141,7 +141,7 @@ var InjectedConnector = class extends Connector {
141
141
  try {
142
142
  const provider = await this.getProvider();
143
143
  if (!provider)
144
- throw new ConnectorNotFoundError();
144
+ throw new (0, _core.ConnectorNotFoundError)();
145
145
  if (provider.on) {
146
146
  provider.on("accountsChanged", this.onAccountsChanged);
147
147
  provider.on("chainChanged", this.onChainChanged);
@@ -151,7 +151,7 @@ var InjectedConnector = class extends Connector {
151
151
  const accounts = await provider.request({
152
152
  method: "eth_requestAccounts"
153
153
  });
154
- const account = getAddress(accounts[0]);
154
+ const account = _utilsjs.getAddress.call(void 0, accounts[0]);
155
155
  let id = await this.getChainId();
156
156
  let unsupported = this.isChainUnsupported(id);
157
157
  if (chainId && id !== chainId) {
@@ -160,94 +160,94 @@ var InjectedConnector = class extends Connector {
160
160
  unsupported = this.isChainUnsupported(id);
161
161
  }
162
162
  if (this.options.shimDisconnect)
163
- getClient().storage?.setItem(this.shimDisconnectKey, true);
163
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.setItem, 'call', _8 => _8(this.shimDisconnectKey, true)]);
164
164
  return { account, chain: { id, unsupported }, provider };
165
165
  } catch (error) {
166
166
  if (this.isUserRejectedRequestError(error))
167
- throw new UserRejectedRequestError(error);
167
+ throw new (0, _core.UserRejectedRequestError)(error);
168
168
  if (error.code === -32002)
169
- throw new ResourceUnavailableError(error);
169
+ throw new (0, _core.ResourceUnavailableError)(error);
170
170
  throw error;
171
171
  }
172
172
  }
173
173
  async disconnect() {
174
174
  const provider = await this.getProvider();
175
- if (!provider?.removeListener)
175
+ if (!_optionalChain([provider, 'optionalAccess', _9 => _9.removeListener]))
176
176
  return;
177
177
  provider.removeListener("accountsChanged", this.onAccountsChanged);
178
178
  provider.removeListener("chainChanged", this.onChainChanged);
179
179
  provider.removeListener("disconnect", this.onDisconnect);
180
180
  if (this.options.shimDisconnect)
181
- getClient().storage?.removeItem(this.shimDisconnectKey);
181
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _10 => _10.storage, 'optionalAccess', _11 => _11.removeItem, 'call', _12 => _12(this.shimDisconnectKey)]);
182
182
  }
183
183
  async getAccount() {
184
184
  const provider = await this.getProvider();
185
185
  if (!provider)
186
- throw new ConnectorNotFoundError();
186
+ throw new (0, _core.ConnectorNotFoundError)();
187
187
  const accounts = await provider.request({
188
188
  method: "eth_accounts"
189
189
  });
190
- return getAddress(accounts[0]);
190
+ return _utilsjs.getAddress.call(void 0, accounts[0]);
191
191
  }
192
192
  async getChainId() {
193
193
  const provider = await this.getProvider();
194
194
  if (!provider)
195
- throw new ConnectorNotFoundError();
196
- return provider.request({ method: "eth_chainId" }).then(normalizeChainId);
195
+ throw new (0, _core.ConnectorNotFoundError)();
196
+ return provider.request({ method: "eth_chainId" }).then(_core.normalizeChainId);
197
197
  }
198
198
  async getProvider() {
199
199
  const provider = this.options.getProvider();
200
200
  if (provider)
201
- __privateSet(this, _provider, provider);
202
- return __privateGet(this, _provider);
201
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, provider);
202
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
203
203
  }
204
204
  async getSigner({ chainId } = {}) {
205
205
  const [provider, account] = await Promise.all([
206
206
  this.getProvider(),
207
207
  this.getAccount()
208
208
  ]);
209
- return new providers.Web3Provider(
209
+ return new _ethers.providers.Web3Provider(
210
210
  provider,
211
211
  chainId
212
212
  ).getSigner(account);
213
213
  }
214
214
  async isAuthorized() {
215
215
  try {
216
- if (this.options.shimDisconnect && !getClient().storage?.getItem(this.shimDisconnectKey))
216
+ if (this.options.shimDisconnect && !_optionalChain([_core.getClient.call(void 0, ), 'access', _13 => _13.storage, 'optionalAccess', _14 => _14.getItem, 'call', _15 => _15(this.shimDisconnectKey)]))
217
217
  return false;
218
218
  const provider = await this.getProvider();
219
219
  if (!provider)
220
- throw new ConnectorNotFoundError();
220
+ throw new (0, _core.ConnectorNotFoundError)();
221
221
  const account = await this.getAccount();
222
222
  return !!account;
223
- } catch {
223
+ } catch (e) {
224
224
  return false;
225
225
  }
226
226
  }
227
227
  async switchChain(chainId) {
228
228
  if (this.options.shimChainChangedDisconnect)
229
- __privateSet(this, _switchingChains, true);
229
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _switchingChains, true);
230
230
  const provider = await this.getProvider();
231
231
  if (!provider)
232
- throw new ConnectorNotFoundError();
233
- const id = hexValue(chainId);
232
+ throw new (0, _core.ConnectorNotFoundError)();
233
+ const id = _utilsjs.hexValue.call(void 0, chainId);
234
234
  try {
235
235
  await provider.request({
236
236
  method: "wallet_switchEthereumChain",
237
237
  params: [{ chainId: id }]
238
238
  });
239
- return this.chains.find((x) => x.id === chainId) ?? {
239
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
240
240
  id: chainId,
241
241
  name: `Chain ${id}`,
242
242
  network: `${id}`,
243
243
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
244
244
  rpcUrls: { default: { http: [""] } }
245
- };
245
+ }));
246
246
  } catch (error) {
247
247
  const chain = this.chains.find((x) => x.id === chainId);
248
248
  if (!chain)
249
- throw new ChainNotConfiguredError({ chainId, connectorId: this.id });
250
- if (error.code === 4902 || error?.data?.originalError?.code === 4902) {
249
+ throw new (0, _core.ChainNotConfiguredError)({ chainId, connectorId: this.id });
250
+ if (error.code === 4902 || _optionalChain([error, 'optionalAccess', _16 => _16.data, 'optionalAccess', _17 => _17.originalError, 'optionalAccess', _18 => _18.code]) === 4902) {
251
251
  try {
252
252
  await provider.request({
253
253
  method: "wallet_addEthereumChain",
@@ -257,7 +257,7 @@ var InjectedConnector = class extends Connector {
257
257
  chainName: chain.name,
258
258
  nativeCurrency: chain.nativeCurrency,
259
259
  rpcUrls: [
260
- chain.rpcUrls.public?.http[0] ?? chain.rpcUrls.default.http[0] ?? ""
260
+ _nullishCoalesce(_nullishCoalesce(_optionalChain([chain, 'access', _19 => _19.rpcUrls, 'access', _20 => _20.public, 'optionalAccess', _21 => _21.http, 'access', _22 => _22[0]]), () => ( chain.rpcUrls.default.http[0])), () => ( ""))
261
261
  ],
262
262
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
263
263
  }
@@ -266,13 +266,13 @@ var InjectedConnector = class extends Connector {
266
266
  return chain;
267
267
  } catch (addError) {
268
268
  if (this.isUserRejectedRequestError(addError))
269
- throw new UserRejectedRequestError(error);
270
- throw new AddChainError();
269
+ throw new (0, _core.UserRejectedRequestError)(error);
270
+ throw new (0, _core.AddChainError)();
271
271
  }
272
272
  }
273
273
  if (this.isUserRejectedRequestError(error))
274
- throw new UserRejectedRequestError(error);
275
- throw new SwitchChainError(error);
274
+ throw new (0, _core.UserRejectedRequestError)(error);
275
+ throw new (0, _core.SwitchChainError)(error);
276
276
  }
277
277
  }
278
278
  async watchAsset({
@@ -283,7 +283,7 @@ var InjectedConnector = class extends Connector {
283
283
  }) {
284
284
  const provider = await this.getProvider();
285
285
  if (!provider)
286
- throw new ConnectorNotFoundError();
286
+ throw new (0, _core.ConnectorNotFoundError)();
287
287
  return provider.request({
288
288
  method: "wallet_watchAsset",
289
289
  params: {
@@ -304,6 +304,6 @@ var InjectedConnector = class extends Connector {
304
304
  _provider = new WeakMap();
305
305
  _switchingChains = new WeakMap();
306
306
 
307
- export {
308
- InjectedConnector
309
- };
307
+
308
+
309
+ exports.InjectedConnector = InjectedConnector;
@@ -2,11 +2,11 @@ import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
2
2
  import { CoinbaseWalletSDKOptions } from '@coinbase/wallet-sdk/dist/CoinbaseWalletSDK';
3
3
  import { Chain } from '@wagmi/core/chains';
4
4
  import { providers } from 'ethers';
5
- import { C as Connector } from './base-caae9601.js';
5
+ import { C as Connector } from './base-6b5431a5.js';
6
6
  import 'abitype';
7
7
  import 'eventemitter3';
8
8
 
9
- type Options = CoinbaseWalletSDKOptions & {
9
+ declare type Options = CoinbaseWalletSDKOptions & {
10
10
  /**
11
11
  * Fallback Ethereum JSON RPC URL
12
12
  * @default ""
@@ -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: [""] } }
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({
@@ -168,7 +168,7 @@ var CoinbaseWalletConnector = class extends Connector {
168
168
  chainName: chain.name,
169
169
  nativeCurrency: chain.nativeCurrency,
170
170
  rpcUrls: [
171
- chain.rpcUrls.public?.http[0] ?? chain.rpcUrls.default.http[0]
171
+ _nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( chain.rpcUrls.default.http[0]))
172
172
  ],
173
173
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
174
174
  }
@@ -176,14 +176,14 @@ var CoinbaseWalletConnector = class extends Connector {
176
176
  });
177
177
  return chain;
178
178
  } catch (addError) {
179
- if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, addError))
180
- throw new UserRejectedRequestError(addError);
181
- throw new AddChainError();
179
+ if (_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, addError))
180
+ throw new (0, _core.UserRejectedRequestError)(addError);
181
+ throw new (0, _core.AddChainError)();
182
182
  }
183
183
  }
184
- if (__privateMethod(this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, error))
185
- throw new UserRejectedRequestError(error);
186
- throw new SwitchChainError(error);
184
+ if (_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isUserRejectedRequestError, isUserRejectedRequestError_fn).call(this, error))
185
+ throw new (0, _core.UserRejectedRequestError)(error);
186
+ throw new (0, _core.SwitchChainError)(error);
187
187
  }
188
188
  }
189
189
  async watchAsset({
@@ -213,6 +213,6 @@ _isUserRejectedRequestError = new WeakSet();
213
213
  isUserRejectedRequestError_fn = function(error) {
214
214
  return /(user rejected)/i.test(error.message);
215
215
  };
216
- export {
217
- CoinbaseWalletConnector
218
- };
216
+
217
+
218
+ exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-caae9601.js';
1
+ export { C as Connector, a as ConnectorData, b as ConnectorEvents } from './base-6b5431a5.js';
2
2
  import '@wagmi/core/chains';
3
3
  import 'abitype';
4
4
  import 'eventemitter3';
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;