@wagmi/connectors 0.3.13 → 0.3.14-cjs

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/safe.js CHANGED
@@ -1,23 +1,23 @@
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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/safe.ts
10
- import { SafeAppProvider } from "@safe-global/safe-apps-provider";
11
- import { default as SafeAppsSDK } from "@safe-global/safe-apps-sdk";
12
- import {
13
- ConnectorNotFoundError,
14
- getClient,
15
- normalizeChainId
16
- } from "@wagmi/core";
17
- import { providers } from "ethers";
18
- import { getAddress } from "ethers/lib/utils.js";
10
+ var _safeappsprovider = require('@safe-global/safe-apps-provider');
11
+ var _safeappssdk = require('@safe-global/safe-apps-sdk'); var _safeappssdk2 = _interopRequireDefault(_safeappssdk);
12
+
13
+
14
+
15
+
16
+ var _core = require('@wagmi/core');
17
+ var _ethers = require('ethers');
18
+ var _utilsjs = require('ethers/lib/utils.js');
19
19
  var _provider, _sdk;
20
- var SafeConnector = class extends Connector {
20
+ var SafeConnector = class extends _chunk5NCTPR6Cjs.Connector {
21
21
  constructor({
22
22
  chains,
23
23
  options: options_
@@ -27,21 +27,21 @@ var SafeConnector = class extends Connector {
27
27
  ...options_
28
28
  };
29
29
  super({ chains, options });
30
- __publicField(this, "id", "safe");
31
- __publicField(this, "name", "Safe");
32
- __publicField(this, "ready", !(typeof window === "undefined") && window?.parent !== window);
33
- __privateAdd(this, _provider, void 0);
34
- __privateAdd(this, _sdk, void 0);
35
- __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
36
- let SDK = SafeAppsSDK;
37
- if (typeof SafeAppsSDK !== "function" && typeof SafeAppsSDK.default === "function")
38
- SDK = SafeAppsSDK.default;
39
- __privateSet(this, _sdk, new SDK(options));
30
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "safe");
31
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "Safe");
32
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", !(typeof window === "undefined") && _optionalChain([window, 'optionalAccess', _ => _.parent]) !== window);
33
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
34
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _sdk, void 0);
35
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
36
+ let SDK = _safeappssdk2.default;
37
+ if (typeof _safeappssdk2.default !== "function" && typeof _safeappssdk2.default.default === "function")
38
+ SDK = _safeappssdk2.default.default;
39
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _sdk, new SDK(options));
40
40
  }
41
41
  async connect() {
42
42
  const provider = await this.getProvider();
43
43
  if (!provider)
44
- throw new ConnectorNotFoundError();
44
+ throw new (0, _core.ConnectorNotFoundError)();
45
45
  if (provider.on) {
46
46
  provider.on("accountsChanged", this.onAccountsChanged);
47
47
  provider.on("chainChanged", this.onChainChanged);
@@ -51,7 +51,7 @@ var SafeConnector = class extends Connector {
51
51
  const account = await this.getAccount();
52
52
  const id = await this.getChainId();
53
53
  if (this.options.shimDisconnect)
54
- getClient().storage?.setItem(this.shimDisconnectKey, true);
54
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _2 => _2.storage, 'optionalAccess', _3 => _3.setItem, 'call', _4 => _4(this.shimDisconnectKey, true)]);
55
55
  return {
56
56
  account,
57
57
  provider,
@@ -60,50 +60,50 @@ var SafeConnector = class extends Connector {
60
60
  }
61
61
  async disconnect() {
62
62
  const provider = await this.getProvider();
63
- if (!provider?.removeListener)
63
+ if (!_optionalChain([provider, 'optionalAccess', _5 => _5.removeListener]))
64
64
  return;
65
65
  provider.removeListener("accountsChanged", this.onAccountsChanged);
66
66
  provider.removeListener("chainChanged", this.onChainChanged);
67
67
  provider.removeListener("disconnect", this.onDisconnect);
68
68
  if (this.options.shimDisconnect)
69
- getClient().storage?.removeItem(this.shimDisconnectKey);
69
+ _optionalChain([_core.getClient.call(void 0, ), 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.removeItem, 'call', _8 => _8(this.shimDisconnectKey)]);
70
70
  }
71
71
  async getAccount() {
72
72
  const provider = await this.getProvider();
73
73
  if (!provider)
74
- throw new ConnectorNotFoundError();
74
+ throw new (0, _core.ConnectorNotFoundError)();
75
75
  const accounts = await provider.request({
76
76
  method: "eth_accounts"
77
77
  });
78
- return getAddress(accounts[0]);
78
+ return _utilsjs.getAddress.call(void 0, accounts[0]);
79
79
  }
80
80
  async getChainId() {
81
81
  const provider = await this.getProvider();
82
82
  if (!provider)
83
- throw new ConnectorNotFoundError();
84
- return normalizeChainId(provider.chainId);
83
+ throw new (0, _core.ConnectorNotFoundError)();
84
+ return _core.normalizeChainId.call(void 0, provider.chainId);
85
85
  }
86
86
  async getProvider() {
87
- if (!__privateGet(this, _provider)) {
88
- const safe = await __privateGet(this, _sdk).safe.getInfo();
87
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider)) {
88
+ const safe = await _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _sdk).safe.getInfo();
89
89
  if (!safe)
90
90
  throw new Error("Could not load Safe information");
91
- __privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
91
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, new (0, _safeappsprovider.SafeAppProvider)(safe, _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _sdk)));
92
92
  }
93
- return __privateGet(this, _provider);
93
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
94
94
  }
95
95
  async getSigner() {
96
96
  const provider = await this.getProvider();
97
97
  const account = await this.getAccount();
98
- return new providers.Web3Provider(provider).getSigner(account);
98
+ return new _ethers.providers.Web3Provider(provider).getSigner(account);
99
99
  }
100
100
  async isAuthorized() {
101
101
  try {
102
- if (this.options.shimDisconnect && !getClient().storage?.getItem(this.shimDisconnectKey))
102
+ if (this.options.shimDisconnect && !_optionalChain([_core.getClient.call(void 0, ), 'access', _9 => _9.storage, 'optionalAccess', _10 => _10.getItem, 'call', _11 => _11(this.shimDisconnectKey)]))
103
103
  return false;
104
104
  const account = await this.getAccount();
105
105
  return !!account;
106
- } catch {
106
+ } catch (e) {
107
107
  return false;
108
108
  }
109
109
  }
@@ -117,6 +117,6 @@ var SafeConnector = class extends Connector {
117
117
  };
118
118
  _provider = new WeakMap();
119
119
  _sdk = new WeakMap();
120
- export {
121
- SafeConnector
122
- };
120
+
121
+
122
+ exports.SafeConnector = SafeConnector;
@@ -55,6 +55,7 @@ type InjectedProviderFlags = {
55
55
  isFrontier?: true;
56
56
  isGamestop?: true;
57
57
  isHyperPay?: true;
58
+ isImToken?: true;
58
59
  isKuCoinWallet?: true;
59
60
  isMathWallet?: true;
60
61
  isMetaMask?: true;
@@ -1,82 +1,82 @@
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/walletConnect.ts
11
- import {
12
- SwitchChainError,
13
- UserRejectedRequestError,
14
- getClient
15
- } from "@wagmi/core";
16
- import { providers } from "ethers";
17
- import { getAddress, hexValue } from "ethers/lib/utils.js";
11
+
12
+
13
+
14
+
15
+ var _core = require('@wagmi/core');
16
+ var _ethers = require('ethers');
17
+ var _utilsjs = require('ethers/lib/utils.js');
18
18
  var NAMESPACE = "eip155";
19
19
  var REQUESTED_CHAINS_KEY = "wagmi.requestedChains";
20
20
  var ADD_ETH_CHAIN_METHOD = "wallet_addEthereumChain";
21
21
  var _provider, _initProviderPromise, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _isChainsStale, isChainsStale_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn, _setRequestedChainsIds, setRequestedChainsIds_fn, _getRequestedChainsIds, getRequestedChainsIds_fn, _getNamespaceChainsIds, getNamespaceChainsIds_fn, _getNamespaceMethods, getNamespaceMethods_fn;
22
- var WalletConnectConnector = class extends Connector {
22
+ var WalletConnectConnector = class extends _chunk5NCTPR6Cjs.Connector {
23
23
  constructor(config) {
24
24
  super({
25
25
  ...config,
26
26
  options: { isNewChainsStale: true, ...config.options }
27
27
  });
28
- __privateAdd(this, _createProvider);
29
- __privateAdd(this, _initProvider);
30
- __privateAdd(this, _isChainsStale);
31
- __privateAdd(this, _setupListeners);
32
- __privateAdd(this, _removeListeners);
33
- __privateAdd(this, _setRequestedChainsIds);
34
- __privateAdd(this, _getRequestedChainsIds);
35
- __privateAdd(this, _getNamespaceChainsIds);
36
- __privateAdd(this, _getNamespaceMethods);
37
- __publicField(this, "id", "walletConnect");
38
- __publicField(this, "name", "WalletConnect");
39
- __publicField(this, "ready", true);
40
- __privateAdd(this, _provider, void 0);
41
- __privateAdd(this, _initProviderPromise, void 0);
42
- __publicField(this, "onAccountsChanged", (accounts) => {
28
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _createProvider);
29
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _initProvider);
30
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _isChainsStale);
31
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _setupListeners);
32
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _removeListeners);
33
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _setRequestedChainsIds);
34
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getRequestedChainsIds);
35
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getNamespaceChainsIds);
36
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getNamespaceMethods);
37
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "walletConnect");
38
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "WalletConnect");
39
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", true);
40
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
41
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _initProviderPromise, void 0);
42
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
43
43
  if (accounts.length === 0)
44
44
  this.emit("disconnect");
45
45
  else
46
- this.emit("change", { account: getAddress(accounts[0]) });
46
+ this.emit("change", { account: _utilsjs.getAddress.call(void 0, accounts[0]) });
47
47
  });
48
- __publicField(this, "onChainChanged", (chainId) => {
48
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
49
49
  const id = Number(chainId);
50
50
  const unsupported = this.isChainUnsupported(id);
51
51
  this.emit("change", { chain: { id, unsupported } });
52
52
  });
53
- __publicField(this, "onDisconnect", () => {
54
- __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
53
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", () => {
54
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
55
55
  this.emit("disconnect");
56
56
  });
57
- __publicField(this, "onDisplayUri", (uri) => {
57
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisplayUri", (uri) => {
58
58
  this.emit("message", { type: "display_uri", data: uri });
59
59
  });
60
- __publicField(this, "onConnect", () => {
61
- this.emit("connect", { provider: __privateGet(this, _provider) });
60
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onConnect", () => {
61
+ this.emit("connect", { provider: _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider) });
62
62
  });
63
- __privateMethod(this, _createProvider, createProvider_fn).call(this);
63
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
64
64
  }
65
65
  async connect({ chainId, pairingTopic } = {}) {
66
66
  try {
67
67
  let targetChainId = chainId;
68
68
  if (!targetChainId) {
69
- const lastUsedChainId = getClient().lastUsedChainId;
69
+ const lastUsedChainId = _core.getClient.call(void 0, ).lastUsedChainId;
70
70
  if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId))
71
71
  targetChainId = lastUsedChainId;
72
72
  else
73
- targetChainId = this.chains[0]?.id;
73
+ targetChainId = _optionalChain([this, 'access', _ => _.chains, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.id]);
74
74
  }
75
75
  if (!targetChainId)
76
76
  throw new Error("No chains found on connector.");
77
77
  const provider = await this.getProvider();
78
- __privateMethod(this, _setupListeners, setupListeners_fn).call(this);
79
- const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
78
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
79
+ const isChainsStale = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
80
80
  if (provider.session && isChainsStale)
81
81
  await provider.disconnect();
82
82
  if (!provider.session || isChainsStale) {
@@ -87,20 +87,20 @@ var WalletConnectConnector = class extends Connector {
87
87
  chains: [targetChainId],
88
88
  optionalChains
89
89
  });
90
- __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
90
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
91
91
  }
92
92
  const accounts = await provider.enable();
93
- const account = getAddress(accounts[0]);
93
+ const account = _utilsjs.getAddress.call(void 0, accounts[0]);
94
94
  const id = await this.getChainId();
95
95
  const unsupported = this.isChainUnsupported(id);
96
96
  return {
97
97
  account,
98
98
  chain: { id, unsupported },
99
- provider: new providers.Web3Provider(provider)
99
+ provider: new _ethers.providers.Web3Provider(provider)
100
100
  };
101
101
  } catch (error) {
102
- if (/user rejected/i.test(error?.message)) {
103
- throw new UserRejectedRequestError(error);
102
+ if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _4 => _4.message]))) {
103
+ throw new (0, _core.UserRejectedRequestError)(error);
104
104
  }
105
105
  throw error;
106
106
  }
@@ -113,31 +113,31 @@ var WalletConnectConnector = class extends Connector {
113
113
  if (!/No matching key/i.test(error.message))
114
114
  throw error;
115
115
  } finally {
116
- __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
117
- __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
116
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
117
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
118
118
  }
119
119
  }
120
120
  async getAccount() {
121
121
  const { accounts } = await this.getProvider();
122
- return getAddress(accounts[0]);
122
+ return _utilsjs.getAddress.call(void 0, accounts[0]);
123
123
  }
124
124
  async getChainId() {
125
125
  const { chainId } = await this.getProvider();
126
126
  return chainId;
127
127
  }
128
128
  async getProvider({ chainId } = {}) {
129
- if (!__privateGet(this, _provider))
130
- await __privateMethod(this, _createProvider, createProvider_fn).call(this);
129
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
130
+ await _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
131
131
  if (chainId)
132
132
  await this.switchChain(chainId);
133
- return __privateGet(this, _provider);
133
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
134
134
  }
135
135
  async getSigner({ chainId } = {}) {
136
136
  const [provider, account] = await Promise.all([
137
137
  this.getProvider({ chainId }),
138
138
  this.getAccount()
139
139
  ]);
140
- return new providers.Web3Provider(provider, chainId).getSigner(account);
140
+ return new _ethers.providers.Web3Provider(provider, chainId).getSigner(account);
141
141
  }
142
142
  async isAuthorized() {
143
143
  try {
@@ -145,58 +145,58 @@ var WalletConnectConnector = class extends Connector {
145
145
  this.getAccount(),
146
146
  this.getProvider()
147
147
  ]);
148
- const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
148
+ const isChainsStale = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
149
149
  if (!account)
150
150
  return false;
151
151
  if (isChainsStale && provider.session) {
152
152
  try {
153
153
  await provider.disconnect();
154
- } catch {
154
+ } catch (e) {
155
155
  }
156
156
  return false;
157
157
  }
158
158
  return true;
159
- } catch {
159
+ } catch (e2) {
160
160
  return false;
161
161
  }
162
162
  }
163
163
  async switchChain(chainId) {
164
164
  const chain = this.chains.find((chain2) => chain2.id === chainId);
165
165
  if (!chain)
166
- throw new SwitchChainError(new Error("chain not found on connector."));
166
+ throw new (0, _core.SwitchChainError)(new Error("chain not found on connector."));
167
167
  try {
168
168
  const provider = await this.getProvider();
169
- const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
170
- const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
169
+ const namespaceChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
170
+ const namespaceMethods = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
171
171
  const isChainApproved = namespaceChains.includes(chainId);
172
172
  if (!isChainApproved && namespaceMethods.includes(ADD_ETH_CHAIN_METHOD)) {
173
173
  await provider.request({
174
174
  method: ADD_ETH_CHAIN_METHOD,
175
175
  params: [
176
176
  {
177
- chainId: hexValue(chain.id),
178
- blockExplorerUrls: [chain.blockExplorers?.default],
177
+ chainId: _utilsjs.hexValue.call(void 0, chain.id),
178
+ blockExplorerUrls: [_optionalChain([chain, 'access', _5 => _5.blockExplorers, 'optionalAccess', _6 => _6.default])],
179
179
  chainName: chain.name,
180
180
  nativeCurrency: chain.nativeCurrency,
181
181
  rpcUrls: [...chain.rpcUrls.default.http]
182
182
  }
183
183
  ]
184
184
  });
185
- const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
185
+ const requestedChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
186
186
  requestedChains.push(chainId);
187
- __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
187
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
188
188
  }
189
189
  await provider.request({
190
190
  method: "wallet_switchEthereumChain",
191
- params: [{ chainId: hexValue(chainId) }]
191
+ params: [{ chainId: _utilsjs.hexValue.call(void 0, chainId) }]
192
192
  });
193
193
  return chain;
194
194
  } catch (error) {
195
- const message = typeof error === "string" ? error : error?.message;
195
+ const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _7 => _7.message]);
196
196
  if (/user rejected request/i.test(message)) {
197
- throw new UserRejectedRequestError(error);
197
+ throw new (0, _core.UserRejectedRequestError)(error);
198
198
  }
199
- throw new SwitchChainError(error);
199
+ throw new (0, _core.SwitchChainError)(error);
200
200
  }
201
201
  }
202
202
  };
@@ -204,10 +204,10 @@ _provider = new WeakMap();
204
204
  _initProviderPromise = new WeakMap();
205
205
  _createProvider = new WeakSet();
206
206
  createProvider_fn = async function() {
207
- if (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
208
- __privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
207
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
208
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _initProviderPromise, _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
209
209
  }
210
- return __privateGet(this, _initProviderPromise);
210
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _initProviderPromise);
211
211
  };
212
212
  _initProvider = new WeakSet();
213
213
  initProvider_fn = async function() {
@@ -215,11 +215,11 @@ initProvider_fn = async function() {
215
215
  default: EthereumProvider,
216
216
  OPTIONAL_EVENTS,
217
217
  OPTIONAL_METHODS
218
- } = await import("@walletconnect/ethereum-provider");
218
+ } = await Promise.resolve().then(() => require("@walletconnect/ethereum-provider"));
219
219
  const [defaultChain, ...optionalChains] = this.chains.map(({ id }) => id);
220
220
  if (defaultChain) {
221
221
  const { projectId, showQrModal = true, qrModalOptions } = this.options;
222
- __privateSet(this, _provider, await EthereumProvider.init({
222
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, await EthereumProvider.init({
223
223
  showQrModal,
224
224
  qrModalOptions,
225
225
  projectId,
@@ -238,40 +238,40 @@ initProvider_fn = async function() {
238
238
  };
239
239
  _isChainsStale = new WeakSet();
240
240
  isChainsStale_fn = function() {
241
- const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
241
+ const namespaceMethods = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
242
242
  if (namespaceMethods.includes(ADD_ETH_CHAIN_METHOD))
243
243
  return false;
244
244
  if (!this.options.isNewChainsStale)
245
245
  return false;
246
- const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
246
+ const requestedChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
247
247
  const connectorChains = this.chains.map(({ id }) => id);
248
- const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
248
+ const namespaceChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
249
249
  if (namespaceChains.length && !namespaceChains.some((id) => connectorChains.includes(id)))
250
250
  return false;
251
251
  return !connectorChains.every((id) => requestedChains.includes(id));
252
252
  };
253
253
  _setupListeners = new WeakSet();
254
254
  setupListeners_fn = function() {
255
- if (!__privateGet(this, _provider))
255
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
256
256
  return;
257
- __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
258
- __privateGet(this, _provider).on("accountsChanged", this.onAccountsChanged);
259
- __privateGet(this, _provider).on("chainChanged", this.onChainChanged);
260
- __privateGet(this, _provider).on("disconnect", this.onDisconnect);
261
- __privateGet(this, _provider).on("session_delete", this.onDisconnect);
262
- __privateGet(this, _provider).on("display_uri", this.onDisplayUri);
263
- __privateGet(this, _provider).on("connect", this.onConnect);
257
+ _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
258
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
259
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
260
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
261
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
262
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("display_uri", this.onDisplayUri);
263
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
264
264
  };
265
265
  _removeListeners = new WeakSet();
266
266
  removeListeners_fn = function() {
267
- if (!__privateGet(this, _provider))
267
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
268
268
  return;
269
- __privateGet(this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
270
- __privateGet(this, _provider).removeListener("chainChanged", this.onChainChanged);
271
- __privateGet(this, _provider).removeListener("disconnect", this.onDisconnect);
272
- __privateGet(this, _provider).removeListener("session_delete", this.onDisconnect);
273
- __privateGet(this, _provider).removeListener("display_uri", this.onDisplayUri);
274
- __privateGet(this, _provider).removeListener("connect", this.onConnect);
269
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
270
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
271
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
272
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
273
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("display_uri", this.onDisplayUri);
274
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
275
275
  };
276
276
  _setRequestedChainsIds = new WeakSet();
277
277
  setRequestedChainsIds_fn = function(chains) {
@@ -284,20 +284,20 @@ getRequestedChainsIds_fn = function() {
284
284
  };
285
285
  _getNamespaceChainsIds = new WeakSet();
286
286
  getNamespaceChainsIds_fn = function() {
287
- if (!__privateGet(this, _provider))
287
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
288
288
  return [];
289
- const chainIds = __privateGet(this, _provider).session?.namespaces[NAMESPACE]?.chains?.map(
289
+ const chainIds = _optionalChain([_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider), 'access', _8 => _8.session, 'optionalAccess', _9 => _9.namespaces, 'access', _10 => _10[NAMESPACE], 'optionalAccess', _11 => _11.chains, 'optionalAccess', _12 => _12.map, 'call', _13 => _13(
290
290
  (chain) => parseInt(chain.split(":")[1] || "")
291
- );
292
- return chainIds ?? [];
291
+ )]);
292
+ return _nullishCoalesce(chainIds, () => ( []));
293
293
  };
294
294
  _getNamespaceMethods = new WeakSet();
295
295
  getNamespaceMethods_fn = function() {
296
- if (!__privateGet(this, _provider))
296
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
297
297
  return [];
298
- const methods = __privateGet(this, _provider).session?.namespaces[NAMESPACE]?.methods;
299
- return methods ?? [];
300
- };
301
- export {
302
- WalletConnectConnector
298
+ const methods = _optionalChain([_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider), 'access', _14 => _14.session, 'optionalAccess', _15 => _15.namespaces, 'access', _16 => _16[NAMESPACE], 'optionalAccess', _17 => _17.methods]);
299
+ return _nullishCoalesce(methods, () => ( []));
303
300
  };
301
+
302
+
303
+ exports.WalletConnectConnector = WalletConnectConnector;