@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.
package/dist/metaMask.js CHANGED
@@ -1,25 +1,25 @@
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 _chunkQRUHVNWKjs = require('./chunk-QRUHVNWK.js');
4
-
5
-
6
- var _chunkZCAPXGBXjs = require('./chunk-ZCAPXGBX.js');
7
- require('./chunk-OQILYQDO.js');
8
-
9
-
10
-
11
-
12
-
13
- var _chunkQYMCVNHTjs = require('./chunk-QYMCVNHT.js');
1
+ import {
2
+ InjectedConnector
3
+ } from "./chunk-QRUHVNWK.js";
4
+ import {
5
+ ConnectorNotFoundError
6
+ } from "./chunk-ZCAPXGBX.js";
7
+ import "./chunk-OQILYQDO.js";
8
+ import {
9
+ __privateAdd,
10
+ __privateGet,
11
+ __privateSet,
12
+ __publicField
13
+ } from "./chunk-QYMCVNHT.js";
14
14
 
15
15
  // src/metaMask.ts
16
-
17
-
18
-
19
-
20
- var _viem = require('viem');
16
+ import {
17
+ ResourceUnavailableRpcError,
18
+ UserRejectedRequestError,
19
+ getAddress
20
+ } from "viem";
21
21
  var _UNSTABLE_shimOnConnectSelectAccount;
22
- var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
22
+ var MetaMaskConnector = class extends InjectedConnector {
23
23
  constructor({
24
24
  chains,
25
25
  options: options_
@@ -29,7 +29,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
29
29
  shimDisconnect: true,
30
30
  getProvider() {
31
31
  function getReady(ethereum2) {
32
- const isMetaMask = !!_optionalChain([ethereum2, 'optionalAccess', _ => _.isMetaMask]);
32
+ const isMetaMask = !!ethereum2?.isMetaMask;
33
33
  if (!isMetaMask)
34
34
  return;
35
35
  if (ethereum2.isBraveWallet && !ethereum2._events && !ethereum2._state)
@@ -67,23 +67,23 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
67
67
  if (typeof window === "undefined")
68
68
  return;
69
69
  const ethereum = window.ethereum;
70
- if (_optionalChain([ethereum, 'optionalAccess', _2 => _2.providers]))
70
+ if (ethereum?.providers)
71
71
  return ethereum.providers.find(getReady);
72
72
  return getReady(ethereum);
73
73
  },
74
74
  ...options_
75
75
  };
76
76
  super({ chains, options });
77
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "metaMask");
78
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
79
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount, void 0);
80
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
77
+ __publicField(this, "id", "metaMask");
78
+ __publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
79
+ __privateAdd(this, _UNSTABLE_shimOnConnectSelectAccount, void 0);
80
+ __privateSet(this, _UNSTABLE_shimOnConnectSelectAccount, options.UNSTABLE_shimOnConnectSelectAccount);
81
81
  }
82
82
  async connect({ chainId } = {}) {
83
83
  try {
84
84
  const provider = await this.getProvider();
85
85
  if (!provider)
86
- throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
86
+ throw new ConnectorNotFoundError();
87
87
  if (provider.on) {
88
88
  provider.on("accountsChanged", this.onAccountsChanged);
89
89
  provider.on("chainChanged", this.onChainChanged);
@@ -91,7 +91,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
91
91
  }
92
92
  this.emit("message", { type: "connecting" });
93
93
  let account = null;
94
- if (_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _UNSTABLE_shimOnConnectSelectAccount) && _optionalChain([this, 'access', _3 => _3.options, 'optionalAccess', _4 => _4.shimDisconnect]) && !_optionalChain([this, 'access', _5 => _5.storage, 'optionalAccess', _6 => _6.getItem, 'call', _7 => _7(this.shimDisconnectKey)])) {
94
+ if (__privateGet(this, _UNSTABLE_shimOnConnectSelectAccount) && this.options?.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey)) {
95
95
  account = await this.getAccount().catch(() => null);
96
96
  const isConnected = !!account;
97
97
  if (isConnected)
@@ -103,8 +103,8 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
103
103
  account = await this.getAccount();
104
104
  } catch (error) {
105
105
  if (this.isUserRejectedRequestError(error))
106
- throw new (0, _viem.UserRejectedRequestError)(error);
107
- if (error.code === new (0, _viem.ResourceUnavailableRpcError)(error).code)
106
+ throw new UserRejectedRequestError(error);
107
+ if (error.code === new ResourceUnavailableRpcError(error).code)
108
108
  throw error;
109
109
  }
110
110
  }
@@ -112,7 +112,7 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
112
112
  const accounts = await provider.request({
113
113
  method: "eth_requestAccounts"
114
114
  });
115
- account = _viem.getAddress.call(void 0, accounts[0]);
115
+ account = getAddress(accounts[0]);
116
116
  }
117
117
  let id = await this.getChainId();
118
118
  let unsupported = this.isChainUnsupported(id);
@@ -121,19 +121,19 @@ var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
121
121
  id = chain.id;
122
122
  unsupported = this.isChainUnsupported(id);
123
123
  }
124
- if (_optionalChain([this, 'access', _8 => _8.options, 'optionalAccess', _9 => _9.shimDisconnect]))
125
- _optionalChain([this, 'access', _10 => _10.storage, 'optionalAccess', _11 => _11.setItem, 'call', _12 => _12(this.shimDisconnectKey, true)]);
124
+ if (this.options?.shimDisconnect)
125
+ this.storage?.setItem(this.shimDisconnectKey, true);
126
126
  return { account, chain: { id, unsupported }, provider };
127
127
  } catch (error) {
128
128
  if (this.isUserRejectedRequestError(error))
129
- throw new (0, _viem.UserRejectedRequestError)(error);
129
+ throw new UserRejectedRequestError(error);
130
130
  if (error.code === -32002)
131
- throw new (0, _viem.ResourceUnavailableRpcError)(error);
131
+ throw new ResourceUnavailableRpcError(error);
132
132
  throw error;
133
133
  }
134
134
  }
135
135
  };
136
136
  _UNSTABLE_shimOnConnectSelectAccount = new WeakMap();
137
-
138
-
139
- exports.MetaMaskConnector = MetaMaskConnector;
137
+ export {
138
+ MetaMaskConnector
139
+ };
@@ -1,73 +1,73 @@
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(); } } 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/mock/connector.ts
14
- var _viem = require('viem');
14
+ import { getAddress as getAddress2 } from "viem";
15
15
 
16
16
  // src/mock/provider.ts
17
- var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);
18
-
17
+ import { default as EventEmitter } from "eventemitter3";
18
+ import { UserRejectedRequestError, getAddress } from "viem";
19
19
  var _options, _walletClient;
20
20
  var MockProvider = class {
21
21
  constructor(options) {
22
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "events", new (0, _eventemitter32.default)());
23
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "chainId");
24
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _options, void 0);
25
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _walletClient, void 0);
22
+ __publicField(this, "events", new EventEmitter());
23
+ __publicField(this, "chainId");
24
+ __privateAdd(this, _options, void 0);
25
+ __privateAdd(this, _walletClient, void 0);
26
26
  this.chainId = options.chainId;
27
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _options, options);
27
+ __privateSet(this, _options, options);
28
28
  }
29
29
  async enable() {
30
- if (_optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _options), 'access', _ => _.flags, 'optionalAccess', _2 => _2.failConnect]))
31
- throw new (0, _viem.UserRejectedRequestError)(new Error("Failed to connect."));
32
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _walletClient))
33
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _walletClient, _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _options).walletClient);
34
- const address = _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _walletClient).account.address;
30
+ if (__privateGet(this, _options).flags?.failConnect)
31
+ throw new UserRejectedRequestError(new Error("Failed to connect."));
32
+ if (!__privateGet(this, _walletClient))
33
+ __privateSet(this, _walletClient, __privateGet(this, _options).walletClient);
34
+ const address = __privateGet(this, _walletClient).account.address;
35
35
  this.events.emit("accountsChanged", [address]);
36
36
  return [address];
37
37
  }
38
38
  async disconnect() {
39
39
  this.events.emit("disconnect");
40
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _walletClient, void 0);
40
+ __privateSet(this, _walletClient, void 0);
41
41
  }
42
42
  async getAccounts() {
43
- const address = _optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _walletClient), 'optionalAccess', _3 => _3.account, 'access', _4 => _4.address]);
43
+ const address = __privateGet(this, _walletClient)?.account.address;
44
44
  if (!address)
45
45
  return [];
46
- return [_viem.getAddress.call(void 0, address)];
46
+ return [getAddress(address)];
47
47
  }
48
48
  getWalletClient() {
49
- const walletClient = _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _walletClient);
49
+ const walletClient = __privateGet(this, _walletClient);
50
50
  if (!walletClient)
51
51
  throw new Error("walletClient not found");
52
52
  return walletClient;
53
53
  }
54
54
  async switchChain(chainId) {
55
- if (_optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _options), 'access', _5 => _5.flags, 'optionalAccess', _6 => _6.failSwitchChain]))
56
- throw new (0, _viem.UserRejectedRequestError)(new Error("Failed to switch chain."));
57
- _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _options).chainId = chainId;
55
+ if (__privateGet(this, _options).flags?.failSwitchChain)
56
+ throw new UserRejectedRequestError(new Error("Failed to switch chain."));
57
+ __privateGet(this, _options).chainId = chainId;
58
58
  this.chainId = chainId;
59
59
  this.events.emit("chainChanged", chainId);
60
60
  }
61
61
  async switchWalletClient(walletClient) {
62
62
  const address = walletClient.account.address;
63
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _walletClient, walletClient);
63
+ __privateSet(this, _walletClient, walletClient);
64
64
  this.events.emit("accountsChanged", [address]);
65
65
  }
66
66
  async watchAsset(_asset) {
67
67
  return true;
68
68
  }
69
69
  async request({ method, params }) {
70
- return _optionalChain([_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _walletClient), 'optionalAccess', _7 => _7.transport, 'access', _8 => _8.request, 'call', _9 => _9({ method, params })]);
70
+ return __privateGet(this, _walletClient)?.transport.request({ method, params });
71
71
  }
72
72
  on(event, listener) {
73
73
  this.events.on(event, listener);
@@ -86,7 +86,7 @@ _walletClient = new WeakMap();
86
86
 
87
87
  // src/mock/connector.ts
88
88
  var _provider, _switchChain, switchChain_fn;
89
- var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
89
+ var MockConnector = class extends Connector {
90
90
  constructor({
91
91
  chains,
92
92
  options
@@ -95,26 +95,26 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
95
95
  chains,
96
96
  options: {
97
97
  ...options,
98
- chainId: _nullishCoalesce(options.chainId, () => ( _optionalChain([chains, 'optionalAccess', _10 => _10[0], 'optionalAccess', _11 => _11.id])))
98
+ chainId: options.chainId ?? chains?.[0]?.id
99
99
  }
100
100
  });
101
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _switchChain);
102
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "mock");
103
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "Mock");
104
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "ready", true);
105
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _provider, void 0);
106
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
101
+ __privateAdd(this, _switchChain);
102
+ __publicField(this, "id", "mock");
103
+ __publicField(this, "name", "Mock");
104
+ __publicField(this, "ready", true);
105
+ __privateAdd(this, _provider, void 0);
106
+ __publicField(this, "onAccountsChanged", (accounts) => {
107
107
  if (accounts.length === 0)
108
108
  this.emit("disconnect");
109
109
  else
110
- this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
110
+ this.emit("change", { account: getAddress2(accounts[0]) });
111
111
  });
112
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
113
- const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
112
+ __publicField(this, "onChainChanged", (chainId) => {
113
+ const id = normalizeChainId(chainId);
114
114
  const unsupported = this.isChainUnsupported(id);
115
115
  this.emit("change", { chain: { id, unsupported } });
116
116
  });
117
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
117
+ __publicField(this, "onDisconnect", () => {
118
118
  this.emit("disconnect");
119
119
  });
120
120
  }
@@ -125,12 +125,12 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
125
125
  provider.on("disconnect", this.onDisconnect);
126
126
  this.emit("message", { type: "connecting" });
127
127
  const accounts = await provider.enable();
128
- const account = _viem.getAddress.call(void 0, accounts[0]);
129
- const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
128
+ const account = getAddress2(accounts[0]);
129
+ const id = normalizeChainId(provider.chainId);
130
130
  const unsupported = this.isChainUnsupported(id);
131
131
  const data = { account, chain: { id, unsupported }, provider };
132
- if (!_optionalChain([this, 'access', _12 => _12.options, 'access', _13 => _13.flags, 'optionalAccess', _14 => _14.noSwitchChain]))
133
- this.switchChain = _chunkQYMCVNHTjs.__privateMethod.call(void 0, this, _switchChain, switchChain_fn);
132
+ if (!this.options.flags?.noSwitchChain)
133
+ this.switchChain = __privateMethod(this, _switchChain, switchChain_fn);
134
134
  return new Promise(
135
135
  (res) => setTimeout(() => res(data), 100)
136
136
  );
@@ -148,19 +148,19 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
148
148
  const account = accounts[0];
149
149
  if (!account)
150
150
  throw new Error("Failed to get account");
151
- return _viem.getAddress.call(void 0, account);
151
+ return getAddress2(account);
152
152
  }
153
153
  async getChainId() {
154
154
  const provider = await this.getProvider();
155
- return _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
155
+ return normalizeChainId(provider.chainId);
156
156
  }
157
157
  async getProvider({ chainId } = {}) {
158
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider) || chainId)
159
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, new MockProvider({
158
+ if (!__privateGet(this, _provider) || chainId)
159
+ __privateSet(this, _provider, new MockProvider({
160
160
  ...this.options,
161
- chainId: _nullishCoalesce(_nullishCoalesce(chainId, () => ( this.options.chainId)), () => ( this.chains[0].id))
161
+ chainId: chainId ?? this.options.chainId ?? this.chains[0].id
162
162
  }));
163
- return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
163
+ return __privateGet(this, _provider);
164
164
  }
165
165
  async getWalletClient() {
166
166
  const provider = await this.getProvider();
@@ -170,8 +170,8 @@ var MockConnector = class extends _chunkQYMCVNHTjs.Connector {
170
170
  try {
171
171
  const provider = await this.getProvider();
172
172
  const account = await provider.getAccounts();
173
- return _nullishCoalesce(_optionalChain([this, 'access', _15 => _15.options, 'access', _16 => _16.flags, 'optionalAccess', _17 => _17.isAuthorized]), () => ( !!account));
174
- } catch (e) {
173
+ return this.options.flags?.isAuthorized ?? !!account;
174
+ } catch {
175
175
  return false;
176
176
  }
177
177
  }
@@ -188,15 +188,15 @@ _switchChain = new WeakSet();
188
188
  switchChain_fn = async function(chainId) {
189
189
  const provider = await this.getProvider();
190
190
  await provider.switchChain(chainId);
191
- return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
191
+ return this.chains.find((x) => x.id === chainId) ?? {
192
192
  id: chainId,
193
193
  name: `Chain ${chainId}`,
194
194
  network: `${chainId}`,
195
195
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
196
196
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
197
- }));
197
+ };
198
+ };
199
+ export {
200
+ MockConnector,
201
+ MockProvider
198
202
  };
199
-
200
-
201
-
202
- exports.MockConnector = MockConnector; exports.MockProvider = MockProvider;
package/dist/safe.js CHANGED
@@ -1,23 +1,23 @@
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 _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
+ ConnectorNotFoundError
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/safe.ts
16
- var _safeappsprovider = require('@safe-global/safe-apps-provider');
17
- var _safeappssdk = require('@safe-global/safe-apps-sdk'); var _safeappssdk2 = _interopRequireDefault(_safeappssdk);
18
- var _viem = require('viem');
16
+ import { SafeAppProvider } from "@safe-global/safe-apps-provider";
17
+ import { default as SafeAppsSDK } from "@safe-global/safe-apps-sdk";
18
+ import { createWalletClient, custom, getAddress } from "viem";
19
19
  var _provider, _sdk;
20
- var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
20
+ var SafeConnector = class extends Connector {
21
21
  constructor({
22
22
  chains,
23
23
  options: options_
@@ -27,21 +27,21 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
27
27
  ...options_
28
28
  };
29
29
  super({ chains, options });
30
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "id", "safe");
31
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "name", "Safe");
32
- _chunkQYMCVNHTjs.__publicField.call(void 0, this, "ready", !(typeof window === "undefined") && _optionalChain([window, 'optionalAccess', _ => _.parent]) !== window);
33
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _provider, void 0);
34
- _chunkQYMCVNHTjs.__privateAdd.call(void 0, this, _sdk, void 0);
35
- _chunkQYMCVNHTjs.__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
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _sdk, new SDK(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));
40
40
  }
41
41
  async connect() {
42
42
  const provider = await this.getProvider();
43
43
  if (!provider)
44
- throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
44
+ throw new 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 _chunkQYMCVNHTjs.Connector {
51
51
  const account = await this.getAccount();
52
52
  const id = await this.getChainId();
53
53
  if (this.options.shimDisconnect)
54
- _optionalChain([this, 'access', _2 => _2.storage, 'optionalAccess', _3 => _3.setItem, 'call', _4 => _4(this.shimDisconnectKey, true)]);
54
+ this.storage?.setItem(this.shimDisconnectKey, true);
55
55
  return {
56
56
  account,
57
57
  chain: { id, unsupported: this.isChainUnsupported(id) }
@@ -59,37 +59,37 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
59
59
  }
60
60
  async disconnect() {
61
61
  const provider = await this.getProvider();
62
- if (!_optionalChain([provider, 'optionalAccess', _5 => _5.removeListener]))
62
+ if (!provider?.removeListener)
63
63
  return;
64
64
  provider.removeListener("accountsChanged", this.onAccountsChanged);
65
65
  provider.removeListener("chainChanged", this.onChainChanged);
66
66
  provider.removeListener("disconnect", this.onDisconnect);
67
67
  if (this.options.shimDisconnect)
68
- _optionalChain([this, 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.removeItem, 'call', _8 => _8(this.shimDisconnectKey)]);
68
+ this.storage?.removeItem(this.shimDisconnectKey);
69
69
  }
70
70
  async getAccount() {
71
71
  const provider = await this.getProvider();
72
72
  if (!provider)
73
- throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
73
+ throw new ConnectorNotFoundError();
74
74
  const accounts = await provider.request({
75
75
  method: "eth_accounts"
76
76
  });
77
- return _viem.getAddress.call(void 0, accounts[0]);
77
+ return getAddress(accounts[0]);
78
78
  }
79
79
  async getChainId() {
80
80
  const provider = await this.getProvider();
81
81
  if (!provider)
82
- throw new (0, _chunkZCAPXGBXjs.ConnectorNotFoundError)();
83
- return _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
82
+ throw new ConnectorNotFoundError();
83
+ return normalizeChainId(provider.chainId);
84
84
  }
85
85
  async getProvider() {
86
- if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider)) {
87
- const safe = await _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _sdk).safe.getInfo();
86
+ if (!__privateGet(this, _provider)) {
87
+ const safe = await __privateGet(this, _sdk).safe.getInfo();
88
88
  if (!safe)
89
89
  throw new Error("Could not load Safe information");
90
- _chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, new (0, _safeappsprovider.SafeAppProvider)(safe, _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _sdk)));
90
+ __privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
91
91
  }
92
- return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
92
+ return __privateGet(this, _provider);
93
93
  }
94
94
  async getWalletClient({
95
95
  chainId
@@ -99,19 +99,19 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
99
99
  const chain = this.chains.find((x) => x.id === chainId);
100
100
  if (!provider)
101
101
  throw new Error("provider is required.");
102
- return _viem.createWalletClient.call(void 0, {
102
+ return createWalletClient({
103
103
  account,
104
104
  chain,
105
- transport: _viem.custom.call(void 0, provider)
105
+ transport: custom(provider)
106
106
  });
107
107
  }
108
108
  async isAuthorized() {
109
109
  try {
110
- if (this.options.shimDisconnect && !_optionalChain([this, 'access', _9 => _9.storage, 'optionalAccess', _10 => _10.getItem, 'call', _11 => _11(this.shimDisconnectKey)]))
110
+ if (this.options.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey))
111
111
  return false;
112
112
  const account = await this.getAccount();
113
113
  return !!account;
114
- } catch (e) {
114
+ } catch {
115
115
  return false;
116
116
  }
117
117
  }
@@ -125,6 +125,6 @@ var SafeConnector = class extends _chunkQYMCVNHTjs.Connector {
125
125
  };
126
126
  _provider = new WeakMap();
127
127
  _sdk = new WeakMap();
128
-
129
-
130
- exports.SafeConnector = SafeConnector;
128
+ export {
129
+ SafeConnector
130
+ };
@@ -57,9 +57,14 @@ type WalletConnectOptions = {
57
57
  showQrModal?: EthereumProviderOptions['showQrModal'];
58
58
  /**
59
59
  * Options of QR code modal.
60
- * @link https://docs.walletconnect.com/2.0/web3modal/options
60
+ * @link https://docs.walletconnect.com/2.0/web/walletConnectModal/modal/options
61
61
  */
62
62
  qrModalOptions?: EthereumProviderOptions['qrModalOptions'];
63
+ /**
64
+ * Option to override default relay url.
65
+ * @link https://docs.walletconnect.com/2.0/web/providers/ethereum
66
+ */
67
+ relayUrl?: string;
63
68
  };
64
69
  type ConnectConfig = {
65
70
  /** Target chain to connect to. */