@wagmi/connectors 2.6.2-cjs → 2.6.3

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,28 +1,28 @@
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');
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";
14
14
 
15
15
  // src/coinbaseWallet.ts
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
- var _viem = require('viem');
16
+ import {
17
+ SwitchChainError,
18
+ UserRejectedRequestError,
19
+ createWalletClient,
20
+ custom,
21
+ getAddress,
22
+ numberToHex
23
+ } from "viem";
24
24
  var _client, _provider;
25
- var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
25
+ var CoinbaseWalletConnector = class extends Connector {
26
26
  constructor({ chains, options }) {
27
27
  super({
28
28
  chains,
@@ -31,23 +31,23 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
31
31
  ...options
32
32
  }
33
33
  });
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) => {
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) => {
40
40
  if (accounts.length === 0)
41
41
  this.emit("disconnect");
42
42
  else
43
- this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
43
+ this.emit("change", { account: getAddress(accounts[0]) });
44
44
  });
45
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
46
- const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
45
+ __publicField(this, "onChainChanged", (chainId) => {
46
+ const id = normalizeChainId(chainId);
47
47
  const unsupported = this.isChainUnsupported(id);
48
48
  this.emit("change", { chain: { id, unsupported } });
49
49
  });
50
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
50
+ __publicField(this, "onDisconnect", () => {
51
51
  this.emit("disconnect");
52
52
  });
53
53
  }
@@ -59,7 +59,7 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.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 = _viem.getAddress.call(void 0, accounts[0]);
62
+ const account = getAddress(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 _chunkQYMCVNHTjs.Connector {
75
75
  if (/(user closed modal|accounts received is empty)/i.test(
76
76
  error.message
77
77
  ))
78
- throw new (0, _viem.UserRejectedRequestError)(error);
78
+ throw new UserRejectedRequestError(error);
79
79
  throw error;
80
80
  }
81
81
  }
82
82
  async disconnect() {
83
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
83
+ if (!__privateGet(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 _chunkQYMCVNHTjs.Connector {
94
94
  const accounts = await provider.request({
95
95
  method: "eth_accounts"
96
96
  });
97
- return _viem.getAddress.call(void 0, accounts[0]);
97
+ return getAddress(accounts[0]);
98
98
  }
99
99
  async getChainId() {
100
100
  const provider = await this.getProvider();
101
- const chainId = _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
101
+ const chainId = normalizeChainId(provider.chainId);
102
102
  return chainId;
103
103
  }
104
104
  async getProvider() {
105
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider)) {
106
- let CoinbaseWalletSDK = (await Promise.resolve().then(() => require("@coinbase/wallet-sdk"))).default;
105
+ if (!__privateGet(this, _provider)) {
106
+ let CoinbaseWalletSDK = (await import("@coinbase/wallet-sdk")).default;
107
107
  if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function")
108
108
  CoinbaseWalletSDK = CoinbaseWalletSDK.default;
109
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _client, new CoinbaseWalletSDK(this.options));
109
+ __privateSet(this, _client, new CoinbaseWalletSDK(this.options));
110
110
  class WalletProvider {
111
111
  }
112
112
  class Client {
113
113
  }
114
- const walletExtensionChainId = _optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _client), 'access', _ => _.walletExtension, 'optionalAccess', _2 => _2.getChainId, 'call', _3 => _3()]);
114
+ const walletExtensionChainId = __privateGet(this, _client).walletExtension?.getChainId();
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 || _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));
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));
121
121
  }
122
- return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
122
+ return __privateGet(this, _provider);
123
123
  }
124
124
  async getWalletClient({
125
125
  chainId
@@ -131,39 +131,39 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
131
131
  const chain = this.chains.find((x) => x.id === chainId);
132
132
  if (!provider)
133
133
  throw new Error("provider is required.");
134
- return _viem.createWalletClient.call(void 0, {
134
+ return createWalletClient({
135
135
  account,
136
136
  chain,
137
- transport: _viem.custom.call(void 0, provider)
137
+ transport: custom(provider)
138
138
  });
139
139
  }
140
140
  async isAuthorized() {
141
141
  try {
142
142
  const account = await this.getAccount();
143
143
  return !!account;
144
- } catch (e) {
144
+ } catch {
145
145
  return false;
146
146
  }
147
147
  }
148
148
  async switchChain(chainId) {
149
149
  const provider = await this.getProvider();
150
- const id = _viem.numberToHex.call(void 0, chainId);
150
+ const id = numberToHex(chainId);
151
151
  try {
152
152
  await provider.request({
153
153
  method: "wallet_switchEthereumChain",
154
154
  params: [{ chainId: id }]
155
155
  });
156
- return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
156
+ return this.chains.find((x) => x.id === chainId) ?? {
157
157
  id: chainId,
158
158
  name: `Chain ${id}`,
159
159
  network: `${id}`,
160
160
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
161
161
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
162
- }));
162
+ };
163
163
  } catch (error) {
164
164
  const chain = this.chains.find((x) => x.id === chainId);
165
165
  if (!chain)
166
- throw new (0, _chunkZCAPXGBXjs.ChainNotConfiguredForConnectorError)({
166
+ throw new ChainNotConfiguredForConnectorError({
167
167
  chainId,
168
168
  connectorId: this.id
169
169
  });
@@ -176,17 +176,17 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
176
176
  chainId: id,
177
177
  chainName: chain.name,
178
178
  nativeCurrency: chain.nativeCurrency,
179
- rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( ""))],
179
+ rpcUrls: [chain.rpcUrls.public?.http[0] ?? ""],
180
180
  blockExplorerUrls: this.getBlockExplorerUrls(chain)
181
181
  }
182
182
  ]
183
183
  });
184
184
  return chain;
185
185
  } catch (error2) {
186
- throw new (0, _viem.UserRejectedRequestError)(error2);
186
+ throw new UserRejectedRequestError(error2);
187
187
  }
188
188
  }
189
- throw new (0, _viem.SwitchChainError)(error);
189
+ throw new SwitchChainError(error);
190
190
  }
191
191
  }
192
192
  async watchAsset({
@@ -212,6 +212,6 @@ var CoinbaseWalletConnector = class extends _chunkQYMCVNHTjs.Connector {
212
212
  };
213
213
  _client = new WeakMap();
214
214
  _provider = new WeakMap();
215
-
216
-
217
- exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
215
+ export {
216
+ CoinbaseWalletConnector
217
+ };
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkZCAPXGBXjs = require('./chunk-ZCAPXGBX.js');
5
-
6
-
7
- var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
8
-
9
-
10
- var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
11
-
12
-
13
-
14
-
15
-
16
- exports.ChainNotConfiguredForConnectorError = _chunkZCAPXGBXjs.ChainNotConfiguredForConnectorError; exports.Connector = _chunkQYMCVNHTjs.Connector; exports.ConnectorNotFoundError = _chunkZCAPXGBXjs.ConnectorNotFoundError; exports.normalizeChainId = _chunkOQILYQDOjs.normalizeChainId;
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
+ } from "./chunk-QYMCVNHT.js";
11
+ export {
12
+ ChainNotConfiguredForConnectorError,
13
+ Connector,
14
+ ConnectorNotFoundError,
15
+ normalizeChainId
16
+ };
package/dist/injected.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkQRUHVNWKjs = require('./chunk-QRUHVNWK.js');
4
- require('./chunk-ZCAPXGBX.js');
5
- require('./chunk-OQILYQDO.js');
6
- require('./chunk-QYMCVNHT.js');
7
-
8
-
9
- exports.InjectedConnector = _chunkQRUHVNWKjs.InjectedConnector;
1
+ import {
2
+ InjectedConnector
3
+ } from "./chunk-QRUHVNWK.js";
4
+ import "./chunk-ZCAPXGBX.js";
5
+ import "./chunk-OQILYQDO.js";
6
+ import "./chunk-QYMCVNHT.js";
7
+ export {
8
+ InjectedConnector
9
+ };
package/dist/ledger.js CHANGED
@@ -1,63 +1,63 @@
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');
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";
12
12
 
13
13
  // src/ledger.ts
14
-
15
-
16
-
17
- var _connectkitloader = require('@ledgerhq/connect-kit-loader');
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
- var _viem = require('viem');
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
26
  var _provider, _initProviderPromise, _isV1, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn;
27
- var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
27
+ var LedgerConnector = class extends Connector {
28
28
  constructor(config) {
29
29
  super({
30
30
  ...config,
31
31
  options: { ...config.options }
32
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) => {
33
+ __privateAdd(this, _createProvider);
34
+ __privateAdd(this, _initProvider);
35
+ __privateAdd(this, _setupListeners);
36
+ __privateAdd(this, _removeListeners);
37
+ __publicField(this, "id", "ledger");
38
+ __publicField(this, "name", "Ledger");
39
+ __publicField(this, "ready", true);
40
+ __privateAdd(this, _provider, void 0);
41
+ __privateAdd(this, _initProviderPromise, void 0);
42
+ __privateAdd(this, _isV1, void 0);
43
+ __publicField(this, "onAccountsChanged", (accounts) => {
44
44
  if (accounts.length === 0)
45
45
  this.emit("disconnect");
46
46
  else
47
- this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
47
+ this.emit("change", { account: getAddress(accounts[0]) });
48
48
  });
49
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
50
- const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
49
+ __publicField(this, "onChainChanged", (chainId) => {
50
+ const id = normalizeChainId(chainId);
51
51
  const unsupported = this.isChainUnsupported(id);
52
52
  this.emit("change", { chain: { id, unsupported } });
53
53
  });
54
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
54
+ __publicField(this, "onDisconnect", () => {
55
55
  this.emit("disconnect");
56
56
  });
57
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onConnect", () => {
57
+ __publicField(this, "onConnect", () => {
58
58
  this.emit("connect", {});
59
59
  });
60
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _isV1, this.walletConnectVersion === 1);
60
+ __privateSet(this, _isV1, this.walletConnectVersion === 1);
61
61
  }
62
62
  get walletConnectVersion() {
63
63
  if (this.options.walletConnectVersion)
@@ -69,7 +69,7 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
69
69
  async connect({ chainId } = {}) {
70
70
  try {
71
71
  const provider = await this.getProvider({ create: true });
72
- _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
72
+ __privateMethod(this, _setupListeners, setupListeners_fn).call(this);
73
73
  if (!provider.session) {
74
74
  this.emit("message", { type: "connecting" });
75
75
  await provider.request({
@@ -90,8 +90,8 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
90
90
  provider
91
91
  };
92
92
  } catch (error) {
93
- if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _ => _.message]))) {
94
- throw new (0, _viem.UserRejectedRequestError)(error);
93
+ if (/user rejected/i.test(error?.message)) {
94
+ throw new UserRejectedRequestError(error);
95
95
  }
96
96
  throw error;
97
97
  }
@@ -99,14 +99,14 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
99
99
  async disconnect() {
100
100
  const provider = await this.getProvider();
101
101
  try {
102
- if (_optionalChain([provider, 'optionalAccess', _2 => _2.disconnect]))
102
+ if (provider?.disconnect)
103
103
  await provider.disconnect();
104
104
  } catch (error) {
105
105
  if (!/No matching key/i.test(error.message))
106
106
  throw error;
107
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");
108
+ __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
109
+ __privateGet(this, _isV1) && typeof localStorage !== "undefined" && localStorage.removeItem("walletconnect");
110
110
  }
111
111
  }
112
112
  async getAccount() {
@@ -114,7 +114,7 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
114
114
  const accounts = await provider.request({
115
115
  method: "eth_accounts"
116
116
  });
117
- const account = _viem.getAddress.call(void 0, accounts[0]);
117
+ const account = getAddress(accounts[0]);
118
118
  return account;
119
119
  }
120
120
  async getChainId() {
@@ -122,17 +122,17 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
122
122
  const chainId = await provider.request({
123
123
  method: "eth_chainId"
124
124
  });
125
- return _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
125
+ return normalizeChainId(chainId);
126
126
  }
127
127
  async getProvider({ chainId, create } = {
128
128
  create: false
129
129
  }) {
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);
130
+ if (!__privateGet(this, _provider) || __privateGet(this, _isV1) && create) {
131
+ await __privateMethod(this, _createProvider, createProvider_fn).call(this);
132
132
  }
133
133
  if (chainId)
134
134
  await this.switchChain(chainId);
135
- return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
135
+ return __privateGet(this, _provider);
136
136
  }
137
137
  async getWalletClient({
138
138
  chainId
@@ -144,33 +144,33 @@ var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
144
144
  const chain = this.chains.find((x) => x.id === chainId);
145
145
  if (!provider)
146
146
  throw new Error("provider is required.");
147
- return _viem.createWalletClient.call(void 0, { account, chain, transport: _viem.custom.call(void 0, provider) });
147
+ return createWalletClient({ account, chain, transport: custom(provider) });
148
148
  }
149
149
  async isAuthorized() {
150
150
  try {
151
151
  const account = await this.getAccount();
152
152
  return !!account;
153
- } catch (e) {
153
+ } catch {
154
154
  return false;
155
155
  }
156
156
  }
157
157
  async switchChain(chainId) {
158
158
  const chain = this.chains.find((chain2) => chain2.id === chainId);
159
159
  if (!chain)
160
- throw new (0, _viem.SwitchChainError)(new Error("chain not found on connector."));
160
+ throw new SwitchChainError(new Error("chain not found on connector."));
161
161
  try {
162
162
  const provider = await this.getProvider();
163
163
  await provider.request({
164
164
  method: "wallet_switchEthereumChain",
165
- params: [{ chainId: _viem.numberToHex.call(void 0, chainId) }]
165
+ params: [{ chainId: numberToHex(chainId) }]
166
166
  });
167
167
  return chain;
168
168
  } catch (error) {
169
- const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _3 => _3.message]);
169
+ const message = typeof error === "string" ? error : error?.message;
170
170
  if (/user rejected request/i.test(message)) {
171
- throw new (0, _viem.UserRejectedRequestError)(error);
171
+ throw new UserRejectedRequestError(error);
172
172
  }
173
- throw new (0, _viem.SwitchChainError)(error);
173
+ throw new SwitchChainError(error);
174
174
  }
175
175
  }
176
176
  };
@@ -179,22 +179,22 @@ _initProviderPromise = new WeakMap();
179
179
  _isV1 = new WeakMap();
180
180
  _createProvider = new WeakSet();
181
181
  createProvider_fn = async function() {
182
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
183
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _initProviderPromise, _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
182
+ if (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
183
+ __privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
184
184
  }
185
- return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _initProviderPromise);
185
+ return __privateGet(this, _initProviderPromise);
186
186
  };
187
187
  _initProvider = new WeakSet();
188
188
  initProvider_fn = async function() {
189
- const connectKit = await _connectkitloader.loadConnectKit.call(void 0, );
189
+ const connectKit = await loadConnectKit();
190
190
  if (this.options.enableDebugLogs) {
191
191
  connectKit.enableDebugLogs();
192
192
  }
193
193
  let checkSupportOptions;
194
- if (_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _isV1)) {
194
+ if (__privateGet(this, _isV1)) {
195
195
  const { chainId, bridge } = this.options;
196
196
  checkSupportOptions = {
197
- providerType: _connectkitloader.SupportedProviders.Ethereum,
197
+ providerType: SupportedProviders.Ethereum,
198
198
  walletConnectVersion: 1,
199
199
  chainId,
200
200
  bridge,
@@ -216,7 +216,7 @@ initProvider_fn = async function() {
216
216
  } = this.options;
217
217
  const optionalChains = this.chains.map(({ id }) => id);
218
218
  checkSupportOptions = {
219
- providerType: _connectkitloader.SupportedProviders.Ethereum,
219
+ providerType: SupportedProviders.Ethereum,
220
220
  walletConnectVersion: 2,
221
221
  projectId,
222
222
  chains: requiredChains,
@@ -234,29 +234,29 @@ initProvider_fn = async function() {
234
234
  };
235
235
  }
236
236
  connectKit.checkSupport(checkSupportOptions);
237
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, await connectKit.getProvider());
237
+ __privateSet(this, _provider, await connectKit.getProvider());
238
238
  };
239
239
  _setupListeners = new WeakSet();
240
240
  setupListeners_fn = function() {
241
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
241
+ if (!__privateGet(this, _provider))
242
242
  return;
243
- _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
244
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
245
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
246
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
247
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
248
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
243
+ __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
244
+ __privateGet(this, _provider).on("accountsChanged", this.onAccountsChanged);
245
+ __privateGet(this, _provider).on("chainChanged", this.onChainChanged);
246
+ __privateGet(this, _provider).on("disconnect", this.onDisconnect);
247
+ __privateGet(this, _provider).on("session_delete", this.onDisconnect);
248
+ __privateGet(this, _provider).on("connect", this.onConnect);
249
249
  };
250
250
  _removeListeners = new WeakSet();
251
251
  removeListeners_fn = function() {
252
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
252
+ if (!__privateGet(this, _provider))
253
253
  return;
254
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
255
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
256
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
257
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
258
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
254
+ __privateGet(this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
255
+ __privateGet(this, _provider).removeListener("chainChanged", this.onChainChanged);
256
+ __privateGet(this, _provider).removeListener("disconnect", this.onDisconnect);
257
+ __privateGet(this, _provider).removeListener("session_delete", this.onDisconnect);
258
+ __privateGet(this, _provider).removeListener("connect", this.onConnect);
259
+ };
260
+ export {
261
+ LedgerConnector
259
262
  };
260
-
261
-
262
- exports.LedgerConnector = LedgerConnector;