@wagmi/connectors 2.6.2 → 2.6.3-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/coinbaseWallet/package.json +1 -1
- package/dist/chunk-OQILYQDO.js +4 -4
- package/dist/chunk-QRUHVNWK.js +73 -73
- package/dist/chunk-QYMCVNHT.js +14 -14
- package/dist/chunk-ZCAPXGBX.js +10 -10
- package/dist/coinbaseWallet.js +58 -58
- package/dist/index.js +16 -16
- package/dist/injected.js +9 -9
- package/dist/ledger.js +83 -83
- package/dist/metaMask.js +37 -37
- package/dist/mock/index.js +63 -63
- package/dist/safe.js +46 -46
- package/dist/walletConnect.d.ts +6 -1
- package/dist/walletConnect.js +109 -111
- package/dist/walletConnectLegacy.js +58 -58
- package/injected/package.json +1 -1
- package/ledger/package.json +1 -1
- package/metaMask/package.json +1 -1
- package/mock/package.json +1 -1
- package/package.json +4 -44
- package/safe/package.json +1 -1
- package/walletConnect/package.json +1 -1
- package/walletConnectLegacy/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
package/dist/injected.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
package/dist/ledger.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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');
|
|
12
12
|
|
|
13
13
|
// src/ledger.ts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _connectkitloader = require('@ledgerhq/connect-kit-loader');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _viem = require('viem');
|
|
26
26
|
var _provider, _initProviderPromise, _isV1, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn;
|
|
27
|
-
var LedgerConnector = class extends Connector {
|
|
27
|
+
var LedgerConnector = class extends _chunkQYMCVNHTjs.Connector {
|
|
28
28
|
constructor(config) {
|
|
29
29
|
super({
|
|
30
30
|
...config,
|
|
31
31
|
options: { ...config.options }
|
|
32
32
|
});
|
|
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) => {
|
|
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) => {
|
|
44
44
|
if (accounts.length === 0)
|
|
45
45
|
this.emit("disconnect");
|
|
46
46
|
else
|
|
47
|
-
this.emit("change", { account: getAddress(accounts[0]) });
|
|
47
|
+
this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
|
|
48
48
|
});
|
|
49
|
-
__publicField(this, "onChainChanged", (chainId) => {
|
|
50
|
-
const id = normalizeChainId(chainId);
|
|
49
|
+
_chunkQYMCVNHTjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
|
|
50
|
+
const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
51
51
|
const unsupported = this.isChainUnsupported(id);
|
|
52
52
|
this.emit("change", { chain: { id, unsupported } });
|
|
53
53
|
});
|
|
54
|
-
__publicField(this, "onDisconnect", () => {
|
|
54
|
+
_chunkQYMCVNHTjs.__publicField.call(void 0, this, "onDisconnect", () => {
|
|
55
55
|
this.emit("disconnect");
|
|
56
56
|
});
|
|
57
|
-
__publicField(this, "onConnect", () => {
|
|
57
|
+
_chunkQYMCVNHTjs.__publicField.call(void 0, this, "onConnect", () => {
|
|
58
58
|
this.emit("connect", {});
|
|
59
59
|
});
|
|
60
|
-
__privateSet(this, _isV1, this.walletConnectVersion === 1);
|
|
60
|
+
_chunkQYMCVNHTjs.__privateSet.call(void 0, 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 Connector {
|
|
|
69
69
|
async connect({ chainId } = {}) {
|
|
70
70
|
try {
|
|
71
71
|
const provider = await this.getProvider({ create: true });
|
|
72
|
-
__privateMethod(this, _setupListeners, setupListeners_fn).call(this);
|
|
72
|
+
_chunkQYMCVNHTjs.__privateMethod.call(void 0, 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 Connector {
|
|
|
90
90
|
provider
|
|
91
91
|
};
|
|
92
92
|
} catch (error) {
|
|
93
|
-
if (/user rejected/i.test(error
|
|
94
|
-
throw new UserRejectedRequestError(error);
|
|
93
|
+
if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _ => _.message]))) {
|
|
94
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
95
95
|
}
|
|
96
96
|
throw error;
|
|
97
97
|
}
|
|
@@ -99,14 +99,14 @@ var LedgerConnector = class extends Connector {
|
|
|
99
99
|
async disconnect() {
|
|
100
100
|
const provider = await this.getProvider();
|
|
101
101
|
try {
|
|
102
|
-
if (provider
|
|
102
|
+
if (_optionalChain([provider, 'optionalAccess', _2 => _2.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
|
-
__privateMethod(this, _removeListeners, removeListeners_fn).call(this);
|
|
109
|
-
__privateGet(this, _isV1) && typeof localStorage !== "undefined" && localStorage.removeItem("walletconnect");
|
|
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");
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
async getAccount() {
|
|
@@ -114,7 +114,7 @@ var LedgerConnector = class extends Connector {
|
|
|
114
114
|
const accounts = await provider.request({
|
|
115
115
|
method: "eth_accounts"
|
|
116
116
|
});
|
|
117
|
-
const account = getAddress(accounts[0]);
|
|
117
|
+
const account = _viem.getAddress.call(void 0, accounts[0]);
|
|
118
118
|
return account;
|
|
119
119
|
}
|
|
120
120
|
async getChainId() {
|
|
@@ -122,17 +122,17 @@ var LedgerConnector = class extends Connector {
|
|
|
122
122
|
const chainId = await provider.request({
|
|
123
123
|
method: "eth_chainId"
|
|
124
124
|
});
|
|
125
|
-
return normalizeChainId(chainId);
|
|
125
|
+
return _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
126
126
|
}
|
|
127
127
|
async getProvider({ chainId, create } = {
|
|
128
128
|
create: false
|
|
129
129
|
}) {
|
|
130
|
-
if (!__privateGet(this, _provider) || __privateGet(this, _isV1) && create) {
|
|
131
|
-
await __privateMethod(this, _createProvider, createProvider_fn).call(this);
|
|
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);
|
|
132
132
|
}
|
|
133
133
|
if (chainId)
|
|
134
134
|
await this.switchChain(chainId);
|
|
135
|
-
return __privateGet(this, _provider);
|
|
135
|
+
return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider);
|
|
136
136
|
}
|
|
137
137
|
async getWalletClient({
|
|
138
138
|
chainId
|
|
@@ -144,33 +144,33 @@ var LedgerConnector = class extends 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 createWalletClient({ account, chain, transport: custom(provider) });
|
|
147
|
+
return _viem.createWalletClient.call(void 0, { account, chain, transport: _viem.custom.call(void 0, provider) });
|
|
148
148
|
}
|
|
149
149
|
async isAuthorized() {
|
|
150
150
|
try {
|
|
151
151
|
const account = await this.getAccount();
|
|
152
152
|
return !!account;
|
|
153
|
-
} catch {
|
|
153
|
+
} catch (e) {
|
|
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 SwitchChainError(new Error("chain not found on connector."));
|
|
160
|
+
throw new (0, _viem.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: numberToHex(chainId) }]
|
|
165
|
+
params: [{ chainId: _viem.numberToHex.call(void 0, chainId) }]
|
|
166
166
|
});
|
|
167
167
|
return chain;
|
|
168
168
|
} catch (error) {
|
|
169
|
-
const message = typeof error === "string" ? error : error
|
|
169
|
+
const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _3 => _3.message]);
|
|
170
170
|
if (/user rejected request/i.test(message)) {
|
|
171
|
-
throw new UserRejectedRequestError(error);
|
|
171
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
172
172
|
}
|
|
173
|
-
throw new SwitchChainError(error);
|
|
173
|
+
throw new (0, _viem.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 (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
|
|
183
|
-
__privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
|
|
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));
|
|
184
184
|
}
|
|
185
|
-
return __privateGet(this, _initProviderPromise);
|
|
185
|
+
return _chunkQYMCVNHTjs.__privateGet.call(void 0, this, _initProviderPromise);
|
|
186
186
|
};
|
|
187
187
|
_initProvider = new WeakSet();
|
|
188
188
|
initProvider_fn = async function() {
|
|
189
|
-
const connectKit = await loadConnectKit();
|
|
189
|
+
const connectKit = await _connectkitloader.loadConnectKit.call(void 0, );
|
|
190
190
|
if (this.options.enableDebugLogs) {
|
|
191
191
|
connectKit.enableDebugLogs();
|
|
192
192
|
}
|
|
193
193
|
let checkSupportOptions;
|
|
194
|
-
if (__privateGet(this, _isV1)) {
|
|
194
|
+
if (_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _isV1)) {
|
|
195
195
|
const { chainId, bridge } = this.options;
|
|
196
196
|
checkSupportOptions = {
|
|
197
|
-
providerType: SupportedProviders.Ethereum,
|
|
197
|
+
providerType: _connectkitloader.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: SupportedProviders.Ethereum,
|
|
219
|
+
providerType: _connectkitloader.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
|
-
__privateSet(this, _provider, await connectKit.getProvider());
|
|
237
|
+
_chunkQYMCVNHTjs.__privateSet.call(void 0, this, _provider, await connectKit.getProvider());
|
|
238
238
|
};
|
|
239
239
|
_setupListeners = new WeakSet();
|
|
240
240
|
setupListeners_fn = function() {
|
|
241
|
-
if (!__privateGet(this, _provider))
|
|
241
|
+
if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
|
|
242
242
|
return;
|
|
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);
|
|
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);
|
|
249
249
|
};
|
|
250
250
|
_removeListeners = new WeakSet();
|
|
251
251
|
removeListeners_fn = function() {
|
|
252
|
-
if (!__privateGet(this, _provider))
|
|
252
|
+
if (!_chunkQYMCVNHTjs.__privateGet.call(void 0, this, _provider))
|
|
253
253
|
return;
|
|
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
|
|
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);
|
|
262
259
|
};
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
exports.LedgerConnector = LedgerConnector;
|
package/dist/metaMask.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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');
|
|
14
14
|
|
|
15
15
|
// src/metaMask.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _viem = require('viem');
|
|
21
21
|
var _UNSTABLE_shimOnConnectSelectAccount;
|
|
22
|
-
var MetaMaskConnector = class extends InjectedConnector {
|
|
22
|
+
var MetaMaskConnector = class extends _chunkQRUHVNWKjs.InjectedConnector {
|
|
23
23
|
constructor({
|
|
24
24
|
chains,
|
|
25
25
|
options: options_
|
|
@@ -29,7 +29,7 @@ var MetaMaskConnector = class extends InjectedConnector {
|
|
|
29
29
|
shimDisconnect: true,
|
|
30
30
|
getProvider() {
|
|
31
31
|
function getReady(ethereum2) {
|
|
32
|
-
const isMetaMask = !!ethereum2
|
|
32
|
+
const isMetaMask = !!_optionalChain([ethereum2, 'optionalAccess', _ => _.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 InjectedConnector {
|
|
|
67
67
|
if (typeof window === "undefined")
|
|
68
68
|
return;
|
|
69
69
|
const ethereum = window.ethereum;
|
|
70
|
-
if (ethereum
|
|
70
|
+
if (_optionalChain([ethereum, 'optionalAccess', _2 => _2.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
|
-
__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);
|
|
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);
|
|
81
81
|
}
|
|
82
82
|
async connect({ chainId } = {}) {
|
|
83
83
|
try {
|
|
84
84
|
const provider = await this.getProvider();
|
|
85
85
|
if (!provider)
|
|
86
|
-
throw new ConnectorNotFoundError();
|
|
86
|
+
throw new (0, _chunkZCAPXGBXjs.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 InjectedConnector {
|
|
|
91
91
|
}
|
|
92
92
|
this.emit("message", { type: "connecting" });
|
|
93
93
|
let account = null;
|
|
94
|
-
if (__privateGet(this, _UNSTABLE_shimOnConnectSelectAccount) && this.options
|
|
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)])) {
|
|
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 InjectedConnector {
|
|
|
103
103
|
account = await this.getAccount();
|
|
104
104
|
} catch (error) {
|
|
105
105
|
if (this.isUserRejectedRequestError(error))
|
|
106
|
-
throw new UserRejectedRequestError(error);
|
|
107
|
-
if (error.code === new ResourceUnavailableRpcError(error).code)
|
|
106
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
107
|
+
if (error.code === new (0, _viem.ResourceUnavailableRpcError)(error).code)
|
|
108
108
|
throw error;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -112,7 +112,7 @@ var MetaMaskConnector = class extends InjectedConnector {
|
|
|
112
112
|
const accounts = await provider.request({
|
|
113
113
|
method: "eth_requestAccounts"
|
|
114
114
|
});
|
|
115
|
-
account = getAddress(accounts[0]);
|
|
115
|
+
account = _viem.getAddress.call(void 0, 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 InjectedConnector {
|
|
|
121
121
|
id = chain.id;
|
|
122
122
|
unsupported = this.isChainUnsupported(id);
|
|
123
123
|
}
|
|
124
|
-
if (this.options
|
|
125
|
-
this.storage
|
|
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)]);
|
|
126
126
|
return { account, chain: { id, unsupported }, provider };
|
|
127
127
|
} catch (error) {
|
|
128
128
|
if (this.isUserRejectedRequestError(error))
|
|
129
|
-
throw new UserRejectedRequestError(error);
|
|
129
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
130
130
|
if (error.code === -32002)
|
|
131
|
-
throw new ResourceUnavailableRpcError(error);
|
|
131
|
+
throw new (0, _viem.ResourceUnavailableRpcError)(error);
|
|
132
132
|
throw error;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
_UNSTABLE_shimOnConnectSelectAccount = new WeakMap();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
exports.MetaMaskConnector = MetaMaskConnector;
|