@wagmi/connectors 3.1.2-cjs → 3.1.2

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,22 +1,22 @@
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
- var _chunkUGBGYVBHjs = require('./chunk-UGBGYVBH.js');
4
-
5
-
6
- var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
7
-
8
-
9
-
10
-
11
-
12
- var _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
1
+ import {
2
+ ConnectorNotFoundError
3
+ } from "./chunk-UGBGYVBH.js";
4
+ import {
5
+ normalizeChainId
6
+ } from "./chunk-OQILYQDO.js";
7
+ import {
8
+ Connector,
9
+ __privateAdd,
10
+ __privateGet,
11
+ __privateSet
12
+ } from "./chunk-W65LBPLT.js";
13
13
 
14
14
  // src/safe.ts
15
- var _safeappsprovider = require('@safe-global/safe-apps-provider');
16
- var _safeappssdk = require('@safe-global/safe-apps-sdk'); var _safeappssdk2 = _interopRequireDefault(_safeappssdk);
17
- var _viem = require('viem');
15
+ import { SafeAppProvider } from "@safe-global/safe-apps-provider";
16
+ import { default as SafeAppsSDK } from "@safe-global/safe-apps-sdk";
17
+ import { createWalletClient, custom, getAddress } from "viem";
18
18
  var _provider, _sdk;
19
- var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
19
+ var SafeConnector = class extends Connector {
20
20
  constructor({
21
21
  chains,
22
22
  options: options_
@@ -28,19 +28,19 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
28
28
  super({ chains, options });
29
29
  this.id = "safe";
30
30
  this.name = "Safe";
31
- this.ready = !(typeof window === "undefined") && _optionalChain([window, 'optionalAccess', _ => _.parent]) !== window;
32
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
33
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _sdk, void 0);
31
+ this.ready = !(typeof window === "undefined") && window?.parent !== window;
32
+ __privateAdd(this, _provider, void 0);
33
+ __privateAdd(this, _sdk, void 0);
34
34
  this.shimDisconnectKey = `${this.id}.shimDisconnect`;
35
- let SDK = _safeappssdk2.default;
36
- if (typeof _safeappssdk2.default !== "function" && typeof _safeappssdk2.default.default === "function")
37
- SDK = _safeappssdk2.default.default;
38
- _chunkW65LBPLTjs.__privateSet.call(void 0, this, _sdk, new SDK(options));
35
+ let SDK = SafeAppsSDK;
36
+ if (typeof SafeAppsSDK !== "function" && typeof SafeAppsSDK.default === "function")
37
+ SDK = SafeAppsSDK.default;
38
+ __privateSet(this, _sdk, new SDK(options));
39
39
  }
40
40
  async connect() {
41
41
  const provider = await this.getProvider();
42
42
  if (!provider)
43
- throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
43
+ throw new ConnectorNotFoundError();
44
44
  if (provider.on) {
45
45
  provider.on("accountsChanged", this.onAccountsChanged);
46
46
  provider.on("chainChanged", this.onChainChanged);
@@ -50,7 +50,7 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
50
50
  const account = await this.getAccount();
51
51
  const id = await this.getChainId();
52
52
  if (this.options.shimDisconnect)
53
- _optionalChain([this, 'access', _2 => _2.storage, 'optionalAccess', _3 => _3.setItem, 'call', _4 => _4(this.shimDisconnectKey, true)]);
53
+ this.storage?.setItem(this.shimDisconnectKey, true);
54
54
  return {
55
55
  account,
56
56
  chain: { id, unsupported: this.isChainUnsupported(id) }
@@ -58,37 +58,37 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
58
58
  }
59
59
  async disconnect() {
60
60
  const provider = await this.getProvider();
61
- if (!_optionalChain([provider, 'optionalAccess', _5 => _5.removeListener]))
61
+ if (!provider?.removeListener)
62
62
  return;
63
63
  provider.removeListener("accountsChanged", this.onAccountsChanged);
64
64
  provider.removeListener("chainChanged", this.onChainChanged);
65
65
  provider.removeListener("disconnect", this.onDisconnect);
66
66
  if (this.options.shimDisconnect)
67
- _optionalChain([this, 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.removeItem, 'call', _8 => _8(this.shimDisconnectKey)]);
67
+ this.storage?.removeItem(this.shimDisconnectKey);
68
68
  }
69
69
  async getAccount() {
70
70
  const provider = await this.getProvider();
71
71
  if (!provider)
72
- throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
72
+ throw new ConnectorNotFoundError();
73
73
  const accounts = await provider.request({
74
74
  method: "eth_accounts"
75
75
  });
76
- return _viem.getAddress.call(void 0, accounts[0]);
76
+ return getAddress(accounts[0]);
77
77
  }
78
78
  async getChainId() {
79
79
  const provider = await this.getProvider();
80
80
  if (!provider)
81
- throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
82
- return _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
81
+ throw new ConnectorNotFoundError();
82
+ return normalizeChainId(provider.chainId);
83
83
  }
84
84
  async getProvider() {
85
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider)) {
86
- const safe = await _chunkW65LBPLTjs.__privateGet.call(void 0, this, _sdk).safe.getInfo();
85
+ if (!__privateGet(this, _provider)) {
86
+ const safe = await __privateGet(this, _sdk).safe.getInfo();
87
87
  if (!safe)
88
88
  throw new Error("Could not load Safe information");
89
- _chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, new (0, _safeappsprovider.SafeAppProvider)(safe, _chunkW65LBPLTjs.__privateGet.call(void 0, this, _sdk)));
89
+ __privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
90
90
  }
91
- return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
91
+ return __privateGet(this, _provider);
92
92
  }
93
93
  async getWalletClient({
94
94
  chainId
@@ -98,19 +98,19 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
98
98
  const chain = this.chains.find((x) => x.id === chainId);
99
99
  if (!provider)
100
100
  throw new Error("provider is required.");
101
- return _viem.createWalletClient.call(void 0, {
101
+ return createWalletClient({
102
102
  account,
103
103
  chain,
104
- transport: _viem.custom.call(void 0, provider)
104
+ transport: custom(provider)
105
105
  });
106
106
  }
107
107
  async isAuthorized() {
108
108
  try {
109
- if (this.options.shimDisconnect && !_optionalChain([this, 'access', _9 => _9.storage, 'optionalAccess', _10 => _10.getItem, 'call', _11 => _11(this.shimDisconnectKey)]))
109
+ if (this.options.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey))
110
110
  return false;
111
111
  const account = await this.getAccount();
112
112
  return !!account;
113
- } catch (e) {
113
+ } catch {
114
114
  return false;
115
115
  }
116
116
  }
@@ -124,6 +124,6 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
124
124
  };
125
125
  _provider = new WeakMap();
126
126
  _sdk = new WeakMap();
127
-
128
-
129
- exports.SafeConnector = SafeConnector;
127
+ export {
128
+ SafeConnector
129
+ };
@@ -1,51 +1,51 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
1
+ import {
2
+ Connector,
3
+ __privateAdd,
4
+ __privateGet,
5
+ __privateMethod,
6
+ __privateSet
7
+ } from "./chunk-W65LBPLT.js";
8
8
 
9
9
  // src/walletConnect.ts
10
- var _utils = require('@walletconnect/utils');
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
- var _viem = require('viem');
10
+ import { normalizeNamespaces } from "@walletconnect/utils";
11
+ import {
12
+ SwitchChainError,
13
+ UserRejectedRequestError,
14
+ createWalletClient,
15
+ custom,
16
+ getAddress,
17
+ numberToHex
18
+ } from "viem";
19
19
  var NAMESPACE = "eip155";
20
20
  var STORE_KEY = "store";
21
21
  var REQUESTED_CHAINS_KEY = "requestedChains";
22
22
  var ADD_ETH_CHAIN_METHOD = "wallet_addEthereumChain";
23
23
  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;
24
- var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
24
+ var WalletConnectConnector = class extends Connector {
25
25
  constructor(config) {
26
26
  super({
27
27
  ...config,
28
28
  options: { isNewChainsStale: true, ...config.options }
29
29
  });
30
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _createProvider);
31
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _initProvider);
32
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _isChainsStale);
33
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _setupListeners);
34
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _removeListeners);
35
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _setRequestedChainsIds);
36
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _getRequestedChainsIds);
37
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _getNamespaceChainsIds);
38
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _getNamespaceMethods);
30
+ __privateAdd(this, _createProvider);
31
+ __privateAdd(this, _initProvider);
32
+ __privateAdd(this, _isChainsStale);
33
+ __privateAdd(this, _setupListeners);
34
+ __privateAdd(this, _removeListeners);
35
+ __privateAdd(this, _setRequestedChainsIds);
36
+ __privateAdd(this, _getRequestedChainsIds);
37
+ __privateAdd(this, _getNamespaceChainsIds);
38
+ __privateAdd(this, _getNamespaceMethods);
39
39
  this.id = "walletConnect";
40
40
  this.name = "WalletConnect";
41
41
  this.ready = true;
42
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
43
- _chunkW65LBPLTjs.__privateAdd.call(void 0, this, _initProviderPromise, void 0);
42
+ __privateAdd(this, _provider, void 0);
43
+ __privateAdd(this, _initProviderPromise, void 0);
44
44
  this.onAccountsChanged = (accounts) => {
45
45
  if (accounts.length === 0)
46
46
  this.emit("disconnect");
47
47
  else
48
- this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
48
+ this.emit("change", { account: getAddress(accounts[0]) });
49
49
  };
50
50
  this.onChainChanged = (chainId) => {
51
51
  const id = Number(chainId);
@@ -53,7 +53,7 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
53
53
  this.emit("change", { chain: { id, unsupported } });
54
54
  };
55
55
  this.onDisconnect = () => {
56
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
56
+ __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
57
57
  this.emit("disconnect");
58
58
  };
59
59
  this.onDisplayUri = (uri) => {
@@ -62,24 +62,24 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
62
62
  this.onConnect = () => {
63
63
  this.emit("connect", {});
64
64
  };
65
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
65
+ __privateMethod(this, _createProvider, createProvider_fn).call(this);
66
66
  }
67
67
  async connect({ chainId, pairingTopic } = {}) {
68
68
  try {
69
69
  let targetChainId = chainId;
70
70
  if (!targetChainId) {
71
- const store = _optionalChain([this, 'access', _ => _.storage, 'optionalAccess', _2 => _2.getItem, 'call', _3 => _3(STORE_KEY)]);
72
- const lastUsedChainId = _optionalChain([store, 'optionalAccess', _4 => _4.state, 'optionalAccess', _5 => _5.data, 'optionalAccess', _6 => _6.chain, 'optionalAccess', _7 => _7.id]);
71
+ const store = this.storage?.getItem(STORE_KEY);
72
+ const lastUsedChainId = store?.state?.data?.chain?.id;
73
73
  if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId))
74
74
  targetChainId = lastUsedChainId;
75
75
  else
76
- targetChainId = _optionalChain([this, 'access', _8 => _8.chains, 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id]);
76
+ targetChainId = this.chains[0]?.id;
77
77
  }
78
78
  if (!targetChainId)
79
79
  throw new Error("No chains found on connector.");
80
80
  const provider = await this.getProvider();
81
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
82
- const isChainsStale = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
81
+ __privateMethod(this, _setupListeners, setupListeners_fn).call(this);
82
+ const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
83
83
  if (provider.session && isChainsStale)
84
84
  await provider.disconnect();
85
85
  if (!provider.session || isChainsStale) {
@@ -90,10 +90,10 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
90
90
  chains: [targetChainId],
91
91
  optionalChains: optionalChains.length ? optionalChains : void 0
92
92
  });
93
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
93
+ __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
94
94
  }
95
95
  const accounts = await provider.enable();
96
- const account = _viem.getAddress.call(void 0, accounts[0]);
96
+ const account = getAddress(accounts[0]);
97
97
  const id = await this.getChainId();
98
98
  const unsupported = this.isChainUnsupported(id);
99
99
  return {
@@ -101,8 +101,8 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
101
101
  chain: { id, unsupported }
102
102
  };
103
103
  } catch (error) {
104
- if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _11 => _11.message]))) {
105
- throw new (0, _viem.UserRejectedRequestError)(error);
104
+ if (/user rejected/i.test(error?.message)) {
105
+ throw new UserRejectedRequestError(error);
106
106
  }
107
107
  throw error;
108
108
  }
@@ -115,24 +115,24 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
115
115
  if (!/No matching key/i.test(error.message))
116
116
  throw error;
117
117
  } finally {
118
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
119
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
118
+ __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
119
+ __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
120
120
  }
121
121
  }
122
122
  async getAccount() {
123
123
  const { accounts } = await this.getProvider();
124
- return _viem.getAddress.call(void 0, accounts[0]);
124
+ return getAddress(accounts[0]);
125
125
  }
126
126
  async getChainId() {
127
127
  const { chainId } = await this.getProvider();
128
128
  return chainId;
129
129
  }
130
130
  async getProvider({ chainId } = {}) {
131
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
132
- await _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
131
+ if (!__privateGet(this, _provider))
132
+ await __privateMethod(this, _createProvider, createProvider_fn).call(this);
133
133
  if (chainId)
134
134
  await this.switchChain(chainId);
135
- return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
135
+ return __privateGet(this, _provider);
136
136
  }
137
137
  async getWalletClient({
138
138
  chainId
@@ -144,10 +144,10 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.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, {
147
+ return createWalletClient({
148
148
  account,
149
149
  chain,
150
- transport: _viem.custom.call(void 0, provider)
150
+ transport: custom(provider)
151
151
  });
152
152
  }
153
153
  async isAuthorized() {
@@ -156,58 +156,58 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
156
156
  this.getAccount(),
157
157
  this.getProvider()
158
158
  ]);
159
- const isChainsStale = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
159
+ const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
160
160
  if (!account)
161
161
  return false;
162
162
  if (isChainsStale && provider.session) {
163
163
  try {
164
164
  await provider.disconnect();
165
- } catch (e) {
165
+ } catch {
166
166
  }
167
167
  return false;
168
168
  }
169
169
  return true;
170
- } catch (e2) {
170
+ } catch {
171
171
  return false;
172
172
  }
173
173
  }
174
174
  async switchChain(chainId) {
175
175
  const chain = this.chains.find((chain2) => chain2.id === chainId);
176
176
  if (!chain)
177
- throw new (0, _viem.SwitchChainError)(new Error("chain not found on connector."));
177
+ throw new SwitchChainError(new Error("chain not found on connector."));
178
178
  try {
179
179
  const provider = await this.getProvider();
180
- const namespaceChains = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
181
- const namespaceMethods = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
180
+ const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
181
+ const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
182
182
  const isChainApproved = namespaceChains.includes(chainId);
183
183
  if (!isChainApproved && namespaceMethods.includes(ADD_ETH_CHAIN_METHOD)) {
184
184
  await provider.request({
185
185
  method: ADD_ETH_CHAIN_METHOD,
186
186
  params: [
187
187
  {
188
- chainId: _viem.numberToHex.call(void 0, chain.id),
189
- blockExplorerUrls: [_optionalChain([chain, 'access', _12 => _12.blockExplorers, 'optionalAccess', _13 => _13.default, 'optionalAccess', _14 => _14.url])],
188
+ chainId: numberToHex(chain.id),
189
+ blockExplorerUrls: [chain.blockExplorers?.default?.url],
190
190
  chainName: chain.name,
191
191
  nativeCurrency: chain.nativeCurrency,
192
192
  rpcUrls: [...chain.rpcUrls.default.http]
193
193
  }
194
194
  ]
195
195
  });
196
- const requestedChains = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
196
+ const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
197
197
  requestedChains.push(chainId);
198
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
198
+ __privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
199
199
  }
200
200
  await provider.request({
201
201
  method: "wallet_switchEthereumChain",
202
- params: [{ chainId: _viem.numberToHex.call(void 0, chainId) }]
202
+ params: [{ chainId: numberToHex(chainId) }]
203
203
  });
204
204
  return chain;
205
205
  } catch (error) {
206
- const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _15 => _15.message]);
206
+ const message = typeof error === "string" ? error : error?.message;
207
207
  if (/user rejected request/i.test(message)) {
208
- throw new (0, _viem.UserRejectedRequestError)(error);
208
+ throw new UserRejectedRequestError(error);
209
209
  }
210
- throw new (0, _viem.SwitchChainError)(error);
210
+ throw new SwitchChainError(error);
211
211
  }
212
212
  }
213
213
  };
@@ -215,14 +215,14 @@ _provider = new WeakMap();
215
215
  _initProviderPromise = new WeakMap();
216
216
  _createProvider = new WeakSet();
217
217
  createProvider_fn = async function() {
218
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
219
- _chunkW65LBPLTjs.__privateSet.call(void 0, this, _initProviderPromise, _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
218
+ if (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
219
+ __privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
220
220
  }
221
- return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _initProviderPromise);
221
+ return __privateGet(this, _initProviderPromise);
222
222
  };
223
223
  _initProvider = new WeakSet();
224
224
  initProvider_fn = async function() {
225
- const { EthereumProvider, OPTIONAL_EVENTS, OPTIONAL_METHODS } = await Promise.resolve().then(() => _interopRequireWildcard(require("@walletconnect/ethereum-provider")));
225
+ const { EthereumProvider, OPTIONAL_EVENTS, OPTIONAL_METHODS } = await import("@walletconnect/ethereum-provider");
226
226
  const [defaultChain, ...optionalChains] = this.chains.map(({ id }) => id);
227
227
  if (defaultChain) {
228
228
  const {
@@ -232,7 +232,7 @@ initProvider_fn = async function() {
232
232
  metadata,
233
233
  relayUrl
234
234
  } = this.options;
235
- _chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, await EthereumProvider.init({
235
+ __privateSet(this, _provider, await EthereumProvider.init({
236
236
  showQrModal,
237
237
  qrModalOptions,
238
238
  projectId,
@@ -253,73 +253,73 @@ initProvider_fn = async function() {
253
253
  };
254
254
  _isChainsStale = new WeakSet();
255
255
  isChainsStale_fn = function() {
256
- const namespaceMethods = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
256
+ const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
257
257
  if (namespaceMethods.includes(ADD_ETH_CHAIN_METHOD))
258
258
  return false;
259
259
  if (!this.options.isNewChainsStale)
260
260
  return false;
261
- const requestedChains = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
261
+ const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
262
262
  const connectorChains = this.chains.map(({ id }) => id);
263
- const namespaceChains = _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
263
+ const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
264
264
  if (namespaceChains.length && !namespaceChains.some((id) => connectorChains.includes(id)))
265
265
  return false;
266
266
  return !connectorChains.every((id) => requestedChains.includes(id));
267
267
  };
268
268
  _setupListeners = new WeakSet();
269
269
  setupListeners_fn = function() {
270
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
270
+ if (!__privateGet(this, _provider))
271
271
  return;
272
- _chunkW65LBPLTjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
273
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
274
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
275
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
276
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
277
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("display_uri", this.onDisplayUri);
278
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
272
+ __privateMethod(this, _removeListeners, removeListeners_fn).call(this);
273
+ __privateGet(this, _provider).on("accountsChanged", this.onAccountsChanged);
274
+ __privateGet(this, _provider).on("chainChanged", this.onChainChanged);
275
+ __privateGet(this, _provider).on("disconnect", this.onDisconnect);
276
+ __privateGet(this, _provider).on("session_delete", this.onDisconnect);
277
+ __privateGet(this, _provider).on("display_uri", this.onDisplayUri);
278
+ __privateGet(this, _provider).on("connect", this.onConnect);
279
279
  };
280
280
  _removeListeners = new WeakSet();
281
281
  removeListeners_fn = function() {
282
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
282
+ if (!__privateGet(this, _provider))
283
283
  return;
284
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
285
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
286
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
287
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
288
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("display_uri", this.onDisplayUri);
289
- _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
284
+ __privateGet(this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
285
+ __privateGet(this, _provider).removeListener("chainChanged", this.onChainChanged);
286
+ __privateGet(this, _provider).removeListener("disconnect", this.onDisconnect);
287
+ __privateGet(this, _provider).removeListener("session_delete", this.onDisconnect);
288
+ __privateGet(this, _provider).removeListener("display_uri", this.onDisplayUri);
289
+ __privateGet(this, _provider).removeListener("connect", this.onConnect);
290
290
  };
291
291
  _setRequestedChainsIds = new WeakSet();
292
292
  setRequestedChainsIds_fn = function(chains) {
293
- _optionalChain([this, 'access', _16 => _16.storage, 'optionalAccess', _17 => _17.setItem, 'call', _18 => _18(REQUESTED_CHAINS_KEY, chains)]);
293
+ this.storage?.setItem(REQUESTED_CHAINS_KEY, chains);
294
294
  };
295
295
  _getRequestedChainsIds = new WeakSet();
296
296
  getRequestedChainsIds_fn = function() {
297
- return _nullishCoalesce(_optionalChain([this, 'access', _19 => _19.storage, 'optionalAccess', _20 => _20.getItem, 'call', _21 => _21(REQUESTED_CHAINS_KEY)]), () => ( []));
297
+ return this.storage?.getItem(REQUESTED_CHAINS_KEY) ?? [];
298
298
  };
299
299
  _getNamespaceChainsIds = new WeakSet();
300
300
  getNamespaceChainsIds_fn = function() {
301
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
301
+ if (!__privateGet(this, _provider))
302
302
  return [];
303
- const namespaces = _optionalChain([_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider), 'access', _22 => _22.session, 'optionalAccess', _23 => _23.namespaces]);
303
+ const namespaces = __privateGet(this, _provider).session?.namespaces;
304
304
  if (!namespaces)
305
305
  return [];
306
- const normalizedNamespaces = _utils.normalizeNamespaces.call(void 0, namespaces);
307
- const chainIds = _optionalChain([normalizedNamespaces, 'access', _24 => _24[NAMESPACE], 'optionalAccess', _25 => _25.chains, 'optionalAccess', _26 => _26.map, 'call', _27 => _27(
306
+ const normalizedNamespaces = normalizeNamespaces(namespaces);
307
+ const chainIds = normalizedNamespaces[NAMESPACE]?.chains?.map(
308
308
  (chain) => parseInt(chain.split(":")[1] || "")
309
- )]);
310
- return _nullishCoalesce(chainIds, () => ( []));
309
+ );
310
+ return chainIds ?? [];
311
311
  };
312
312
  _getNamespaceMethods = new WeakSet();
313
313
  getNamespaceMethods_fn = function() {
314
- if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
314
+ if (!__privateGet(this, _provider))
315
315
  return [];
316
- const namespaces = _optionalChain([_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider), 'access', _28 => _28.session, 'optionalAccess', _29 => _29.namespaces]);
316
+ const namespaces = __privateGet(this, _provider).session?.namespaces;
317
317
  if (!namespaces)
318
318
  return [];
319
- const normalizedNamespaces = _utils.normalizeNamespaces.call(void 0, namespaces);
320
- const methods = _optionalChain([normalizedNamespaces, 'access', _30 => _30[NAMESPACE], 'optionalAccess', _31 => _31.methods]);
321
- return _nullishCoalesce(methods, () => ( []));
319
+ const normalizedNamespaces = normalizeNamespaces(namespaces);
320
+ const methods = normalizedNamespaces[NAMESPACE]?.methods;
321
+ return methods ?? [];
322
+ };
323
+ export {
324
+ WalletConnectConnector
322
325
  };
323
-
324
-
325
- exports.WalletConnectConnector = WalletConnectConnector;