@wagmi/connectors 3.1.8 → 3.1.9-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/{base-2fe21778.d.ts → base-24d0a67f.d.ts} +1 -0
- package/dist/chunk-OQILYQDO.js +4 -4
- package/dist/{chunk-ZJ3P53W7.js → chunk-P4NRLOY7.js} +67 -65
- package/dist/chunk-UGBGYVBH.js +5 -5
- package/dist/chunk-W65LBPLT.js +13 -13
- package/dist/coinbaseWallet.d.ts +1 -1
- package/dist/coinbaseWallet.js +51 -51
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -16
- package/dist/injected.d.ts +1 -1
- package/dist/injected.js +9 -9
- package/dist/ledger.d.ts +1 -1
- package/dist/ledger.js +75 -75
- package/dist/metaMask.d.ts +1 -1
- package/dist/metaMask.js +34 -34
- package/dist/mock/index.d.ts +1 -1
- package/dist/mock/index.js +55 -55
- package/dist/safe.d.ts +1 -1
- package/dist/safe.js +42 -42
- package/dist/walletConnect.d.ts +1 -1
- package/dist/walletConnect.js +101 -101
- package/dist/walletConnectLegacy.d.ts +1 -1
- package/dist/walletConnectLegacy.js +51 -51
- package/package.json +3 -4
package/dist/chunk-OQILYQDO.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/normalizeChainId.ts
|
|
2
2
|
function normalizeChainId(chainId) {
|
|
3
3
|
if (typeof chainId === "string")
|
|
4
4
|
return Number.parseInt(
|
|
@@ -10,6 +10,6 @@ function normalizeChainId(chainId) {
|
|
|
10
10
|
return chainId;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.normalizeChainId = normalizeChainId;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
var _chunkUGBGYVBHjs = require('./chunk-UGBGYVBH.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkOQILYQDOjs = require('./chunk-OQILYQDO.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkW65LBPLTjs = require('./chunk-W65LBPLT.js');
|
|
14
14
|
|
|
15
15
|
// src/injected.ts
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _viem = require('viem');
|
|
25
25
|
|
|
26
26
|
// src/utils/getInjectedName.ts
|
|
27
27
|
function getInjectedName(ethereum) {
|
|
@@ -82,6 +82,8 @@ function getInjectedName(ethereum) {
|
|
|
82
82
|
return "Nova Wallet";
|
|
83
83
|
if (provider.isOkxWallet || provider.isOKExWallet)
|
|
84
84
|
return "OKX Wallet";
|
|
85
|
+
if (provider.isOktoWallet)
|
|
86
|
+
return "Okto Wallet";
|
|
85
87
|
if (provider.isOneInchIOSWallet || provider.isOneInchAndroidWallet)
|
|
86
88
|
return "1inch Wallet";
|
|
87
89
|
if (provider.isOneKey)
|
|
@@ -123,7 +125,7 @@ function getInjectedName(ethereum) {
|
|
|
123
125
|
if (provider.isMetaMask)
|
|
124
126
|
return "MetaMask";
|
|
125
127
|
};
|
|
126
|
-
if (ethereum.providers
|
|
128
|
+
if (_optionalChain([ethereum, 'access', _ => _.providers, 'optionalAccess', _2 => _2.length])) {
|
|
127
129
|
const nameSet = /* @__PURE__ */ new Set();
|
|
128
130
|
let unknownCount = 1;
|
|
129
131
|
for (const provider of ethereum.providers) {
|
|
@@ -137,14 +139,14 @@ function getInjectedName(ethereum) {
|
|
|
137
139
|
const names = [...nameSet];
|
|
138
140
|
if (names.length)
|
|
139
141
|
return names;
|
|
140
|
-
return names[0]
|
|
142
|
+
return _nullishCoalesce(names[0], () => ( "Injected"));
|
|
141
143
|
}
|
|
142
|
-
return getName(ethereum)
|
|
144
|
+
return _nullishCoalesce(getName(ethereum), () => ( "Injected"));
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// src/injected.ts
|
|
146
148
|
var _provider;
|
|
147
|
-
var InjectedConnector = class extends Connector {
|
|
149
|
+
var InjectedConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
148
150
|
constructor({
|
|
149
151
|
chains,
|
|
150
152
|
options: options_
|
|
@@ -155,7 +157,7 @@ var InjectedConnector = class extends Connector {
|
|
|
155
157
|
if (typeof window === "undefined")
|
|
156
158
|
return;
|
|
157
159
|
const ethereum = window.ethereum;
|
|
158
|
-
if (ethereum
|
|
160
|
+
if (_optionalChain([ethereum, 'optionalAccess', _3 => _3.providers]) && ethereum.providers.length > 0)
|
|
159
161
|
return ethereum.providers[0];
|
|
160
162
|
return ethereum;
|
|
161
163
|
},
|
|
@@ -163,18 +165,18 @@ var InjectedConnector = class extends Connector {
|
|
|
163
165
|
};
|
|
164
166
|
super({ chains, options });
|
|
165
167
|
this.id = "injected";
|
|
166
|
-
__privateAdd(this, _provider, void 0);
|
|
168
|
+
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
167
169
|
this.shimDisconnectKey = `${this.id}.shimDisconnect`;
|
|
168
170
|
this.onAccountsChanged = (accounts) => {
|
|
169
171
|
if (accounts.length === 0)
|
|
170
172
|
this.emit("disconnect");
|
|
171
173
|
else
|
|
172
174
|
this.emit("change", {
|
|
173
|
-
account: getAddress(accounts[0])
|
|
175
|
+
account: _viem.getAddress.call(void 0, accounts[0])
|
|
174
176
|
});
|
|
175
177
|
};
|
|
176
178
|
this.onChainChanged = (chainId) => {
|
|
177
|
-
const id = normalizeChainId(chainId);
|
|
179
|
+
const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
178
180
|
const unsupported = this.isChainUnsupported(id);
|
|
179
181
|
this.emit("change", { chain: { id, unsupported } });
|
|
180
182
|
};
|
|
@@ -189,7 +191,7 @@ var InjectedConnector = class extends Connector {
|
|
|
189
191
|
}
|
|
190
192
|
this.emit("disconnect");
|
|
191
193
|
if (this.options.shimDisconnect)
|
|
192
|
-
this.storage
|
|
194
|
+
_optionalChain([this, 'access', _4 => _4.storage, 'optionalAccess', _5 => _5.removeItem, 'call', _6 => _6(this.shimDisconnectKey)]);
|
|
193
195
|
};
|
|
194
196
|
const provider = options.getProvider();
|
|
195
197
|
if (typeof options.name === "string")
|
|
@@ -212,7 +214,7 @@ var InjectedConnector = class extends Connector {
|
|
|
212
214
|
try {
|
|
213
215
|
const provider = await this.getProvider();
|
|
214
216
|
if (!provider)
|
|
215
|
-
throw new ConnectorNotFoundError();
|
|
217
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
216
218
|
if (provider.on) {
|
|
217
219
|
provider.on("accountsChanged", this.onAccountsChanged);
|
|
218
220
|
provider.on("chainChanged", this.onChainChanged);
|
|
@@ -222,7 +224,7 @@ var InjectedConnector = class extends Connector {
|
|
|
222
224
|
const accounts = await provider.request({
|
|
223
225
|
method: "eth_requestAccounts"
|
|
224
226
|
});
|
|
225
|
-
const account = getAddress(accounts[0]);
|
|
227
|
+
const account = _viem.getAddress.call(void 0, accounts[0]);
|
|
226
228
|
let id = await this.getChainId();
|
|
227
229
|
let unsupported = this.isChainUnsupported(id);
|
|
228
230
|
if (chainId && id !== chainId) {
|
|
@@ -231,46 +233,46 @@ var InjectedConnector = class extends Connector {
|
|
|
231
233
|
unsupported = this.isChainUnsupported(id);
|
|
232
234
|
}
|
|
233
235
|
if (this.options.shimDisconnect)
|
|
234
|
-
this.storage
|
|
236
|
+
_optionalChain([this, 'access', _7 => _7.storage, 'optionalAccess', _8 => _8.setItem, 'call', _9 => _9(this.shimDisconnectKey, true)]);
|
|
235
237
|
return { account, chain: { id, unsupported } };
|
|
236
238
|
} catch (error) {
|
|
237
239
|
if (this.isUserRejectedRequestError(error))
|
|
238
|
-
throw new UserRejectedRequestError(error);
|
|
240
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
239
241
|
if (error.code === -32002)
|
|
240
|
-
throw new ResourceUnavailableRpcError(error);
|
|
242
|
+
throw new (0, _viem.ResourceUnavailableRpcError)(error);
|
|
241
243
|
throw error;
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
async disconnect() {
|
|
245
247
|
const provider = await this.getProvider();
|
|
246
|
-
if (!provider
|
|
248
|
+
if (!_optionalChain([provider, 'optionalAccess', _10 => _10.removeListener]))
|
|
247
249
|
return;
|
|
248
250
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
249
251
|
provider.removeListener("chainChanged", this.onChainChanged);
|
|
250
252
|
provider.removeListener("disconnect", this.onDisconnect);
|
|
251
253
|
if (this.options.shimDisconnect)
|
|
252
|
-
this.storage
|
|
254
|
+
_optionalChain([this, 'access', _11 => _11.storage, 'optionalAccess', _12 => _12.removeItem, 'call', _13 => _13(this.shimDisconnectKey)]);
|
|
253
255
|
}
|
|
254
256
|
async getAccount() {
|
|
255
257
|
const provider = await this.getProvider();
|
|
256
258
|
if (!provider)
|
|
257
|
-
throw new ConnectorNotFoundError();
|
|
259
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
258
260
|
const accounts = await provider.request({
|
|
259
261
|
method: "eth_accounts"
|
|
260
262
|
});
|
|
261
|
-
return getAddress(accounts[0]);
|
|
263
|
+
return _viem.getAddress.call(void 0, accounts[0]);
|
|
262
264
|
}
|
|
263
265
|
async getChainId() {
|
|
264
266
|
const provider = await this.getProvider();
|
|
265
267
|
if (!provider)
|
|
266
|
-
throw new ConnectorNotFoundError();
|
|
267
|
-
return provider.request({ method: "eth_chainId" }).then(normalizeChainId);
|
|
268
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
269
|
+
return provider.request({ method: "eth_chainId" }).then(_chunkOQILYQDOjs.normalizeChainId);
|
|
268
270
|
}
|
|
269
271
|
async getProvider() {
|
|
270
272
|
const provider = this.options.getProvider();
|
|
271
273
|
if (provider)
|
|
272
|
-
__privateSet(this, _provider, provider);
|
|
273
|
-
return __privateGet(this, _provider);
|
|
274
|
+
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, provider);
|
|
275
|
+
return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
|
|
274
276
|
}
|
|
275
277
|
async getWalletClient({
|
|
276
278
|
chainId
|
|
@@ -282,30 +284,30 @@ var InjectedConnector = class extends Connector {
|
|
|
282
284
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
283
285
|
if (!provider)
|
|
284
286
|
throw new Error("provider is required.");
|
|
285
|
-
return createWalletClient({
|
|
287
|
+
return _viem.createWalletClient.call(void 0, {
|
|
286
288
|
account,
|
|
287
289
|
chain,
|
|
288
|
-
transport: custom(provider)
|
|
290
|
+
transport: _viem.custom.call(void 0, provider)
|
|
289
291
|
});
|
|
290
292
|
}
|
|
291
293
|
async isAuthorized() {
|
|
292
294
|
try {
|
|
293
|
-
if (this.options.shimDisconnect && !this.storage
|
|
295
|
+
if (this.options.shimDisconnect && !_optionalChain([this, 'access', _14 => _14.storage, 'optionalAccess', _15 => _15.getItem, 'call', _16 => _16(this.shimDisconnectKey)]))
|
|
294
296
|
return false;
|
|
295
297
|
const provider = await this.getProvider();
|
|
296
298
|
if (!provider)
|
|
297
|
-
throw new ConnectorNotFoundError();
|
|
299
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
298
300
|
const account = await this.getAccount();
|
|
299
301
|
return !!account;
|
|
300
|
-
} catch {
|
|
302
|
+
} catch (e) {
|
|
301
303
|
return false;
|
|
302
304
|
}
|
|
303
305
|
}
|
|
304
306
|
async switchChain(chainId) {
|
|
305
307
|
const provider = await this.getProvider();
|
|
306
308
|
if (!provider)
|
|
307
|
-
throw new ConnectorNotFoundError();
|
|
308
|
-
const id = numberToHex(chainId);
|
|
309
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
310
|
+
const id = _viem.numberToHex.call(void 0, chainId);
|
|
309
311
|
try {
|
|
310
312
|
await Promise.all([
|
|
311
313
|
provider.request({
|
|
@@ -314,26 +316,26 @@ var InjectedConnector = class extends Connector {
|
|
|
314
316
|
}),
|
|
315
317
|
new Promise(
|
|
316
318
|
(res) => this.on("change", ({ chain }) => {
|
|
317
|
-
if (chain
|
|
319
|
+
if (_optionalChain([chain, 'optionalAccess', _17 => _17.id]) === chainId)
|
|
318
320
|
res();
|
|
319
321
|
})
|
|
320
322
|
)
|
|
321
323
|
]);
|
|
322
|
-
return this.chains.find((x) => x.id === chainId)
|
|
324
|
+
return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
|
|
323
325
|
id: chainId,
|
|
324
326
|
name: `Chain ${id}`,
|
|
325
327
|
network: `${id}`,
|
|
326
328
|
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
327
329
|
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
328
|
-
};
|
|
330
|
+
}));
|
|
329
331
|
} catch (error) {
|
|
330
332
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
331
333
|
if (!chain)
|
|
332
|
-
throw new ChainNotConfiguredForConnectorError({
|
|
334
|
+
throw new (0, _chunkUGBGYVBHjs.ChainNotConfiguredForConnectorError)({
|
|
333
335
|
chainId,
|
|
334
336
|
connectorId: this.id
|
|
335
337
|
});
|
|
336
|
-
if (error.code === 4902 || error
|
|
338
|
+
if (error.code === 4902 || _optionalChain([error, 'optionalAccess', _18 => _18.data, 'optionalAccess', _19 => _19.originalError, 'optionalAccess', _20 => _20.code]) === 4902) {
|
|
337
339
|
try {
|
|
338
340
|
await provider.request({
|
|
339
341
|
method: "wallet_addEthereumChain",
|
|
@@ -342,24 +344,24 @@ var InjectedConnector = class extends Connector {
|
|
|
342
344
|
chainId: id,
|
|
343
345
|
chainName: chain.name,
|
|
344
346
|
nativeCurrency: chain.nativeCurrency,
|
|
345
|
-
rpcUrls: [chain.rpcUrls.public
|
|
347
|
+
rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _21 => _21.rpcUrls, 'access', _22 => _22.public, 'optionalAccess', _23 => _23.http, 'access', _24 => _24[0]]), () => ( ""))],
|
|
346
348
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
347
349
|
}
|
|
348
350
|
]
|
|
349
351
|
});
|
|
350
352
|
const currentChainId = await this.getChainId();
|
|
351
353
|
if (currentChainId !== chainId)
|
|
352
|
-
throw new UserRejectedRequestError(
|
|
354
|
+
throw new (0, _viem.UserRejectedRequestError)(
|
|
353
355
|
new Error("User rejected switch after adding network.")
|
|
354
356
|
);
|
|
355
357
|
return chain;
|
|
356
358
|
} catch (error2) {
|
|
357
|
-
throw new UserRejectedRequestError(error2);
|
|
359
|
+
throw new (0, _viem.UserRejectedRequestError)(error2);
|
|
358
360
|
}
|
|
359
361
|
}
|
|
360
362
|
if (this.isUserRejectedRequestError(error))
|
|
361
|
-
throw new UserRejectedRequestError(error);
|
|
362
|
-
throw new SwitchChainError(error);
|
|
363
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
364
|
+
throw new (0, _viem.SwitchChainError)(error);
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
async watchAsset({
|
|
@@ -370,7 +372,7 @@ var InjectedConnector = class extends Connector {
|
|
|
370
372
|
}) {
|
|
371
373
|
const provider = await this.getProvider();
|
|
372
374
|
if (!provider)
|
|
373
|
-
throw new ConnectorNotFoundError();
|
|
375
|
+
throw new (0, _chunkUGBGYVBHjs.ConnectorNotFoundError)();
|
|
374
376
|
return provider.request({
|
|
375
377
|
method: "wallet_watchAsset",
|
|
376
378
|
params: {
|
|
@@ -390,6 +392,6 @@ var InjectedConnector = class extends Connector {
|
|
|
390
392
|
};
|
|
391
393
|
_provider = new WeakMap();
|
|
392
394
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
exports.InjectedConnector = InjectedConnector;
|
package/dist/chunk-UGBGYVBH.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/errors.ts
|
|
2
2
|
var ChainNotConfiguredForConnectorError = class extends Error {
|
|
3
3
|
constructor({
|
|
4
4
|
chainId,
|
|
@@ -16,7 +16,7 @@ var ConnectorNotFoundError = class extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.ChainNotConfiguredForConnectorError = ChainNotConfiguredForConnectorError; exports.ConnectorNotFoundError = ConnectorNotFoundError;
|
package/dist/chunk-W65LBPLT.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
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(); } }var __accessCheck = (obj, member, msg) => {
|
|
2
2
|
if (!member.has(obj))
|
|
3
3
|
throw TypeError("Cannot " + msg);
|
|
4
4
|
};
|
|
@@ -22,11 +22,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// src/base.ts
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var Connector = class extends
|
|
25
|
+
var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);
|
|
26
|
+
var _chains = require('viem/chains');
|
|
27
|
+
var Connector = class extends _eventemitter32.default {
|
|
28
28
|
constructor({
|
|
29
|
-
chains = [mainnet, goerli],
|
|
29
|
+
chains = [_chains.mainnet, _chains.goerli],
|
|
30
30
|
options
|
|
31
31
|
}) {
|
|
32
32
|
super();
|
|
@@ -34,7 +34,7 @@ var Connector = class extends EventEmitter {
|
|
|
34
34
|
this.options = options;
|
|
35
35
|
}
|
|
36
36
|
getBlockExplorerUrls(chain) {
|
|
37
|
-
const { default: blockExplorer, ...blockExplorers } = chain.blockExplorers
|
|
37
|
+
const { default: blockExplorer, ...blockExplorers } = _nullishCoalesce(chain.blockExplorers, () => ( {}));
|
|
38
38
|
if (blockExplorer)
|
|
39
39
|
return [
|
|
40
40
|
blockExplorer.url,
|
|
@@ -49,10 +49,10 @@ var Connector = class extends EventEmitter {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateMethod = __privateMethod; exports.Connector = Connector;
|
package/dist/coinbaseWallet.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
2
2
|
import { CoinbaseWalletSDKOptions } from '@coinbase/wallet-sdk/dist/CoinbaseWalletSDK';
|
|
3
3
|
import { Chain } from 'viem/chains';
|
|
4
|
-
import { C as Connector, c as WalletClient } from './base-
|
|
4
|
+
import { C as Connector, c as WalletClient } from './base-24d0a67f.js';
|
|
5
5
|
import 'eventemitter3';
|
|
6
6
|
import 'viem';
|
|
7
7
|
|
package/dist/coinbaseWallet.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
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');
|
|
13
13
|
|
|
14
14
|
// src/coinbaseWallet.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _viem = require('viem');
|
|
23
23
|
var _client, _provider;
|
|
24
|
-
var CoinbaseWalletConnector = class extends Connector {
|
|
24
|
+
var CoinbaseWalletConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
25
25
|
constructor({ chains, options }) {
|
|
26
26
|
super({
|
|
27
27
|
chains,
|
|
@@ -33,16 +33,16 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
33
33
|
this.id = "coinbaseWallet";
|
|
34
34
|
this.name = "Coinbase Wallet";
|
|
35
35
|
this.ready = true;
|
|
36
|
-
__privateAdd(this, _client, void 0);
|
|
37
|
-
__privateAdd(this, _provider, void 0);
|
|
36
|
+
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _client, void 0);
|
|
37
|
+
_chunkW65LBPLTjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
38
38
|
this.onAccountsChanged = (accounts) => {
|
|
39
39
|
if (accounts.length === 0)
|
|
40
40
|
this.emit("disconnect");
|
|
41
41
|
else
|
|
42
|
-
this.emit("change", { account: getAddress(accounts[0]) });
|
|
42
|
+
this.emit("change", { account: _viem.getAddress.call(void 0, accounts[0]) });
|
|
43
43
|
};
|
|
44
44
|
this.onChainChanged = (chainId) => {
|
|
45
|
-
const id = normalizeChainId(chainId);
|
|
45
|
+
const id = _chunkOQILYQDOjs.normalizeChainId.call(void 0, chainId);
|
|
46
46
|
const unsupported = this.isChainUnsupported(id);
|
|
47
47
|
this.emit("change", { chain: { id, unsupported } });
|
|
48
48
|
};
|
|
@@ -58,7 +58,7 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
58
58
|
provider.on("disconnect", this.onDisconnect);
|
|
59
59
|
this.emit("message", { type: "connecting" });
|
|
60
60
|
const accounts = await provider.enable();
|
|
61
|
-
const account = getAddress(accounts[0]);
|
|
61
|
+
const account = _viem.getAddress.call(void 0, accounts[0]);
|
|
62
62
|
let id = await this.getChainId();
|
|
63
63
|
let unsupported = this.isChainUnsupported(id);
|
|
64
64
|
if (chainId && id !== chainId) {
|
|
@@ -74,12 +74,12 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
74
74
|
if (/(user closed modal|accounts received is empty)/i.test(
|
|
75
75
|
error.message
|
|
76
76
|
))
|
|
77
|
-
throw new UserRejectedRequestError(error);
|
|
77
|
+
throw new (0, _viem.UserRejectedRequestError)(error);
|
|
78
78
|
throw error;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
async disconnect() {
|
|
82
|
-
if (!__privateGet(this, _provider))
|
|
82
|
+
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider))
|
|
83
83
|
return;
|
|
84
84
|
const provider = await this.getProvider();
|
|
85
85
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
@@ -93,32 +93,32 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
93
93
|
const accounts = await provider.request({
|
|
94
94
|
method: "eth_accounts"
|
|
95
95
|
});
|
|
96
|
-
return getAddress(accounts[0]);
|
|
96
|
+
return _viem.getAddress.call(void 0, accounts[0]);
|
|
97
97
|
}
|
|
98
98
|
async getChainId() {
|
|
99
99
|
const provider = await this.getProvider();
|
|
100
|
-
const chainId = normalizeChainId(provider.chainId);
|
|
100
|
+
const chainId = _chunkOQILYQDOjs.normalizeChainId.call(void 0, provider.chainId);
|
|
101
101
|
return chainId;
|
|
102
102
|
}
|
|
103
103
|
async getProvider() {
|
|
104
|
-
if (!__privateGet(this, _provider)) {
|
|
105
|
-
let CoinbaseWalletSDK = (await
|
|
104
|
+
if (!_chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider)) {
|
|
105
|
+
let CoinbaseWalletSDK = (await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/wallet-sdk")))).default;
|
|
106
106
|
if (typeof CoinbaseWalletSDK !== "function" && typeof CoinbaseWalletSDK.default === "function")
|
|
107
107
|
CoinbaseWalletSDK = CoinbaseWalletSDK.default;
|
|
108
|
-
__privateSet(this, _client, new CoinbaseWalletSDK(this.options));
|
|
108
|
+
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _client, new CoinbaseWalletSDK(this.options));
|
|
109
109
|
class WalletProvider {
|
|
110
110
|
}
|
|
111
111
|
class Client {
|
|
112
112
|
}
|
|
113
|
-
const walletExtensionChainId = __privateGet(this, _client).walletExtension
|
|
113
|
+
const walletExtensionChainId = _optionalChain([_chunkW65LBPLTjs.__privateGet.call(void 0, this, _client), 'access', _ => _.walletExtension, 'optionalAccess', _2 => _2.getChainId, 'call', _3 => _3()]);
|
|
114
114
|
const chain = this.chains.find(
|
|
115
115
|
(chain2) => this.options.chainId ? chain2.id === this.options.chainId : chain2.id === walletExtensionChainId
|
|
116
116
|
) || this.chains[0];
|
|
117
|
-
const chainId = this.options.chainId || chain
|
|
118
|
-
const jsonRpcUrl = this.options.jsonRpcUrl || chain
|
|
119
|
-
__privateSet(this, _provider, __privateGet(this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
|
|
117
|
+
const chainId = this.options.chainId || _optionalChain([chain, 'optionalAccess', _4 => _4.id]);
|
|
118
|
+
const jsonRpcUrl = this.options.jsonRpcUrl || _optionalChain([chain, 'optionalAccess', _5 => _5.rpcUrls, 'access', _6 => _6.default, 'access', _7 => _7.http, 'access', _8 => _8[0]]);
|
|
119
|
+
_chunkW65LBPLTjs.__privateSet.call(void 0, this, _provider, _chunkW65LBPLTjs.__privateGet.call(void 0, this, _client).makeWeb3Provider(jsonRpcUrl, chainId));
|
|
120
120
|
}
|
|
121
|
-
return __privateGet(this, _provider);
|
|
121
|
+
return _chunkW65LBPLTjs.__privateGet.call(void 0, this, _provider);
|
|
122
122
|
}
|
|
123
123
|
async getWalletClient({
|
|
124
124
|
chainId
|
|
@@ -130,39 +130,39 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
130
130
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
131
131
|
if (!provider)
|
|
132
132
|
throw new Error("provider is required.");
|
|
133
|
-
return createWalletClient({
|
|
133
|
+
return _viem.createWalletClient.call(void 0, {
|
|
134
134
|
account,
|
|
135
135
|
chain,
|
|
136
|
-
transport: custom(provider)
|
|
136
|
+
transport: _viem.custom.call(void 0, provider)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
async isAuthorized() {
|
|
140
140
|
try {
|
|
141
141
|
const account = await this.getAccount();
|
|
142
142
|
return !!account;
|
|
143
|
-
} catch {
|
|
143
|
+
} catch (e) {
|
|
144
144
|
return false;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
async switchChain(chainId) {
|
|
148
148
|
const provider = await this.getProvider();
|
|
149
|
-
const id = numberToHex(chainId);
|
|
149
|
+
const id = _viem.numberToHex.call(void 0, chainId);
|
|
150
150
|
try {
|
|
151
151
|
await provider.request({
|
|
152
152
|
method: "wallet_switchEthereumChain",
|
|
153
153
|
params: [{ chainId: id }]
|
|
154
154
|
});
|
|
155
|
-
return this.chains.find((x) => x.id === chainId)
|
|
155
|
+
return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
|
|
156
156
|
id: chainId,
|
|
157
157
|
name: `Chain ${id}`,
|
|
158
158
|
network: `${id}`,
|
|
159
159
|
nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
|
|
160
160
|
rpcUrls: { default: { http: [""] }, public: { http: [""] } }
|
|
161
|
-
};
|
|
161
|
+
}));
|
|
162
162
|
} catch (error) {
|
|
163
163
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
164
164
|
if (!chain)
|
|
165
|
-
throw new ChainNotConfiguredForConnectorError({
|
|
165
|
+
throw new (0, _chunkUGBGYVBHjs.ChainNotConfiguredForConnectorError)({
|
|
166
166
|
chainId,
|
|
167
167
|
connectorId: this.id
|
|
168
168
|
});
|
|
@@ -175,17 +175,17 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
175
175
|
chainId: id,
|
|
176
176
|
chainName: chain.name,
|
|
177
177
|
nativeCurrency: chain.nativeCurrency,
|
|
178
|
-
rpcUrls: [chain.rpcUrls.public
|
|
178
|
+
rpcUrls: [_nullishCoalesce(_optionalChain([chain, 'access', _9 => _9.rpcUrls, 'access', _10 => _10.public, 'optionalAccess', _11 => _11.http, 'access', _12 => _12[0]]), () => ( ""))],
|
|
179
179
|
blockExplorerUrls: this.getBlockExplorerUrls(chain)
|
|
180
180
|
}
|
|
181
181
|
]
|
|
182
182
|
});
|
|
183
183
|
return chain;
|
|
184
184
|
} catch (error2) {
|
|
185
|
-
throw new UserRejectedRequestError(error2);
|
|
185
|
+
throw new (0, _viem.UserRejectedRequestError)(error2);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
throw new SwitchChainError(error);
|
|
188
|
+
throw new (0, _viem.SwitchChainError)(error);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
async watchAsset({
|
|
@@ -211,6 +211,6 @@ var CoinbaseWalletConnector = class extends Connector {
|
|
|
211
211
|
};
|
|
212
212
|
_client = new WeakMap();
|
|
213
213
|
_provider = new WeakMap();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as Connector, a as ConnectorData, b as ConnectorEvents, W as WindowProvider } from './base-
|
|
1
|
+
export { C as Connector, a as ConnectorData, b as ConnectorEvents, W as WindowProvider } from './base-24d0a67f.js';
|
|
2
2
|
import 'eventemitter3';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|