@wagmi/core 0.2.0-next.5 → 0.2.0-next.8

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.
Files changed (41) hide show
  1. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +135 -149
  2. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +135 -149
  3. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +136 -150
  4. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +96 -153
  5. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +96 -153
  6. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +96 -153
  7. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +91 -122
  8. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +91 -122
  9. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +91 -122
  10. package/dist/base-7ffc0425.cjs.prod.js +541 -0
  11. package/dist/base-82f423a9.esm.js +515 -0
  12. package/dist/base-b3073ce2.cjs.dev.js +541 -0
  13. package/dist/{classPrivateMethodGet-38b54c7a.cjs.dev.js → classPrivateMethodGet-0dc9fedc.cjs.dev.js} +1 -1
  14. package/dist/{classPrivateMethodGet-c9db96d6.esm.js → classPrivateMethodGet-1c660f09.esm.js} +1 -1
  15. package/dist/{classPrivateMethodGet-0e9a7925.cjs.prod.js → classPrivateMethodGet-c084b176.cjs.prod.js} +1 -1
  16. package/dist/declarations/src/actions/accounts/connect.d.ts +12 -3
  17. package/dist/declarations/src/actions/accounts/index.d.ts +1 -1
  18. package/dist/declarations/src/actions/accounts/switchNetwork.d.ts +1 -1
  19. package/dist/declarations/src/actions/index.d.ts +1 -1
  20. package/dist/declarations/src/client.d.ts +1 -1
  21. package/dist/declarations/src/connectors/base.d.ts +7 -1
  22. package/dist/declarations/src/connectors/coinbaseWallet.d.ts +9 -0
  23. package/dist/declarations/src/constants/abis.d.ts +2 -0
  24. package/dist/declarations/src/constants/blockExplorers.d.ts +9 -0
  25. package/dist/declarations/src/constants/chains.d.ts +16 -6
  26. package/dist/declarations/src/constants/index.d.ts +6 -2
  27. package/dist/declarations/src/constants/keys.d.ts +2 -0
  28. package/dist/declarations/src/constants/rpcs.d.ts +7 -0
  29. package/dist/declarations/src/index.d.ts +8 -5
  30. package/dist/declarations/src/types/index.d.ts +10 -5
  31. package/dist/wagmi-core.cjs.dev.js +518 -1020
  32. package/dist/wagmi-core.cjs.prod.js +518 -1020
  33. package/dist/wagmi-core.esm.js +516 -1021
  34. package/package.json +2 -2
  35. package/dist/base-09a653f3.cjs.dev.js +0 -453
  36. package/dist/base-824c3b6d.esm.js +0 -430
  37. package/dist/base-d8123d5f.cjs.prod.js +0 -453
  38. package/dist/declarations/src/constants/abis/erc1155.d.ts +0 -17
  39. package/dist/declarations/src/constants/abis/erc20.d.ts +0 -38
  40. package/dist/declarations/src/constants/abis/erc721.d.ts +0 -15
  41. package/dist/declarations/src/constants/abis/index.d.ts +0 -3
@@ -0,0 +1,515 @@
1
+ import EventEmitter from 'eventemitter3';
2
+
3
+ function _checkPrivateRedeclaration(obj, privateCollection) {
4
+ if (privateCollection.has(obj)) {
5
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
6
+ }
7
+ }
8
+
9
+ function _classPrivateFieldInitSpec(obj, privateMap, value) {
10
+ _checkPrivateRedeclaration(obj, privateMap);
11
+ privateMap.set(obj, value);
12
+ }
13
+
14
+ function _defineProperty(obj, key, value) {
15
+ if (key in obj) {
16
+ Object.defineProperty(obj, key, {
17
+ value: value,
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true
21
+ });
22
+ } else {
23
+ obj[key] = value;
24
+ }
25
+
26
+ return obj;
27
+ }
28
+
29
+ function _classApplyDescriptorGet(receiver, descriptor) {
30
+ if (descriptor.get) {
31
+ return descriptor.get.call(receiver);
32
+ }
33
+
34
+ return descriptor.value;
35
+ }
36
+
37
+ function _classExtractFieldDescriptor(receiver, privateMap, action) {
38
+ if (!privateMap.has(receiver)) {
39
+ throw new TypeError("attempted to " + action + " private field on non-instance");
40
+ }
41
+
42
+ return privateMap.get(receiver);
43
+ }
44
+
45
+ function _classPrivateFieldGet(receiver, privateMap) {
46
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
47
+ return _classApplyDescriptorGet(receiver, descriptor);
48
+ }
49
+
50
+ function _classApplyDescriptorSet(receiver, descriptor, value) {
51
+ if (descriptor.set) {
52
+ descriptor.set.call(receiver, value);
53
+ } else {
54
+ if (!descriptor.writable) {
55
+ throw new TypeError("attempted to set read only private field");
56
+ }
57
+
58
+ descriptor.value = value;
59
+ }
60
+ }
61
+
62
+ function _classPrivateFieldSet(receiver, privateMap, value) {
63
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
64
+ _classApplyDescriptorSet(receiver, descriptor, value);
65
+ return value;
66
+ }
67
+
68
+ const etherscanBlockExplorers = {
69
+ mainnet: {
70
+ name: 'Etherscan',
71
+ url: 'https://etherscan.io'
72
+ },
73
+ ropsten: {
74
+ name: 'Etherscan',
75
+ url: 'https://ropsten.etherscan.io'
76
+ },
77
+ rinkeby: {
78
+ name: 'Etherscan',
79
+ url: 'https://rinkeby.etherscan.io'
80
+ },
81
+ goerli: {
82
+ name: 'Etherscan',
83
+ url: 'https://goerli.etherscan.io'
84
+ },
85
+ kovan: {
86
+ name: 'Etherscan',
87
+ url: 'https://kovan.etherscan.io'
88
+ },
89
+ optimism: {
90
+ name: 'Etherscan',
91
+ url: 'https://optimistic.etherscan.io'
92
+ },
93
+ optimismKovan: {
94
+ name: 'Etherscan',
95
+ url: 'https://kovan-optimistic.etherscan.io'
96
+ },
97
+ polygon: {
98
+ name: 'PolygonScan',
99
+ url: 'https://polygonscan.com'
100
+ },
101
+ polygonMumbai: {
102
+ name: 'PolygonScan',
103
+ url: 'https://mumbai.polygonscan.com'
104
+ },
105
+ arbitrum: {
106
+ name: 'Arbiscan',
107
+ url: 'https://arbiscan.io'
108
+ },
109
+ arbitrumRinkeby: {
110
+ name: 'Arbiscan',
111
+ url: 'https://testnet.arbiscan.io'
112
+ }
113
+ };
114
+
115
+ const defaultAlchemyId = '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC';
116
+
117
+ const alchemyRpcUrls = {
118
+ mainnet: 'https://eth-mainnet.alchemyapi.io/v2',
119
+ ropsten: 'https://eth-ropsten.alchemyapi.io/v2',
120
+ rinkeby: 'https://eth-rinkeby.alchemyapi.io/v2',
121
+ goerli: 'https://eth-goerli.alchemyapi.io/v2',
122
+ kovan: 'https://eth-kovan.alchemyapi.io/v2',
123
+ optimism: 'https://opt-mainnet.g.alchemy.com/v2',
124
+ optimismKovan: 'https://opt-kovan.g.alchemy.com/v2',
125
+ polygon: 'https://polygon-mainnet.g.alchemy.com/v2',
126
+ polygonMumbai: 'https://polygon-mumbai.g.alchemy.com/v2',
127
+ arbitrum: 'https://arb-mainnet.g.alchemy.com/v2',
128
+ arbitrumRinkeby: 'https://arb-rinkeby.g.alchemy.com/v2'
129
+ };
130
+ const infuraRpcUrls = {
131
+ mainnet: 'https://mainnet.infura.io/v3',
132
+ ropsten: 'https://ropsten.infura.io/v3',
133
+ rinkeby: 'https://rinkeby.infura.io/v3',
134
+ goerli: 'https://goerli.infura.io/v3',
135
+ kovan: 'https://kovan.infura.io/v3',
136
+ optimism: 'https://optimism-mainnet.infura.io/v3',
137
+ optimismKovan: 'https://optimism-kovan.infura.io/v3',
138
+ polygon: 'https://polygon-mainnet.infura.io/v3',
139
+ polygonMumbai: 'https://polygon-mumbai.infura.io/v3',
140
+ arbitrum: 'https://arbitrum-mainnet.infura.io/v3',
141
+ arbitrumRinkeby: 'https://arbitrum-rinkeby.infura.io/v3'
142
+ };
143
+
144
+ const chainId = {
145
+ mainnet: 1,
146
+ ropsten: 3,
147
+ rinkeby: 4,
148
+ goerli: 5,
149
+ kovan: 42,
150
+ optimism: 10,
151
+ optimismKovan: 69,
152
+ polygon: 137,
153
+ polygonMumbai: 80001,
154
+ arbitrum: 42161,
155
+ arbitrumRinkeby: 421611,
156
+ localhost: 1337,
157
+ hardhat: 31337
158
+ };
159
+ const chain = {
160
+ mainnet: {
161
+ id: chainId.mainnet,
162
+ name: 'Mainnet',
163
+ nativeCurrency: {
164
+ name: 'Ether',
165
+ symbol: 'ETH',
166
+ decimals: 18
167
+ },
168
+ rpcUrls: {
169
+ alchemy: alchemyRpcUrls.mainnet,
170
+ infura: infuraRpcUrls.mainnet,
171
+ default: "".concat(alchemyRpcUrls.mainnet, "/").concat(defaultAlchemyId)
172
+ },
173
+ blockExplorers: {
174
+ etherscan: etherscanBlockExplorers.mainnet,
175
+ default: etherscanBlockExplorers.mainnet
176
+ }
177
+ },
178
+ ropsten: {
179
+ id: chainId.ropsten,
180
+ name: 'Ropsten',
181
+ nativeCurrency: {
182
+ name: 'Ropsten Ether',
183
+ symbol: 'ropETH',
184
+ decimals: 18
185
+ },
186
+ rpcUrls: {
187
+ alchemy: alchemyRpcUrls.ropsten,
188
+ infura: infuraRpcUrls.ropsten,
189
+ default: "".concat(alchemyRpcUrls.ropsten, "/").concat(defaultAlchemyId)
190
+ },
191
+ blockExplorers: {
192
+ etherscan: etherscanBlockExplorers.ropsten,
193
+ default: etherscanBlockExplorers.ropsten
194
+ },
195
+ testnet: true
196
+ },
197
+ rinkeby: {
198
+ id: chainId.rinkeby,
199
+ name: 'Rinkeby',
200
+ nativeCurrency: {
201
+ name: 'Rinkeby Ether',
202
+ symbol: 'rETH',
203
+ decimals: 18
204
+ },
205
+ rpcUrls: {
206
+ alchemy: alchemyRpcUrls.rinkeby,
207
+ infura: infuraRpcUrls.rinkeby,
208
+ default: "".concat(alchemyRpcUrls.rinkeby, "/").concat(defaultAlchemyId)
209
+ },
210
+ blockExplorers: {
211
+ etherscan: etherscanBlockExplorers.rinkeby,
212
+ default: etherscanBlockExplorers.rinkeby
213
+ },
214
+ testnet: true
215
+ },
216
+ goerli: {
217
+ id: chainId.goerli,
218
+ name: 'Goerli',
219
+ nativeCurrency: {
220
+ name: 'Goerli Ether',
221
+ symbol: 'gETH',
222
+ decimals: 18
223
+ },
224
+ rpcUrls: {
225
+ alchemy: alchemyRpcUrls.goerli,
226
+ infura: infuraRpcUrls.goerli,
227
+ default: "".concat(alchemyRpcUrls.goerli, "/").concat(defaultAlchemyId)
228
+ },
229
+ blockExplorers: {
230
+ etherscan: etherscanBlockExplorers.goerli,
231
+ default: etherscanBlockExplorers.goerli
232
+ },
233
+ testnet: true
234
+ },
235
+ kovan: {
236
+ id: chainId.kovan,
237
+ name: 'Kovan',
238
+ nativeCurrency: {
239
+ name: 'Kovan Ether',
240
+ symbol: 'kETH',
241
+ decimals: 18
242
+ },
243
+ rpcUrls: {
244
+ alchemy: alchemyRpcUrls.kovan,
245
+ infura: infuraRpcUrls.kovan,
246
+ default: "".concat(alchemyRpcUrls.kovan, "/").concat(defaultAlchemyId)
247
+ },
248
+ blockExplorers: {
249
+ etherscan: etherscanBlockExplorers.kovan,
250
+ default: etherscanBlockExplorers.kovan
251
+ },
252
+ testnet: true
253
+ },
254
+ optimism: {
255
+ id: chainId.optimism,
256
+ name: 'Optimism',
257
+ nativeCurrency: {
258
+ name: 'Ether',
259
+ symbol: 'ETH',
260
+ decimals: 18
261
+ },
262
+ rpcUrls: {
263
+ alchemy: alchemyRpcUrls.optimism,
264
+ infura: infuraRpcUrls.optimism,
265
+ default: ['https://mainnet.optimism.io']
266
+ },
267
+ blockExplorers: {
268
+ etherscan: etherscanBlockExplorers.optimism,
269
+ default: etherscanBlockExplorers.optimism
270
+ }
271
+ },
272
+ optimismKovan: {
273
+ id: chainId.optimismKovan,
274
+ name: 'Optimism Kovan',
275
+ nativeCurrency: {
276
+ name: 'Kovan Ether',
277
+ symbol: 'KOR',
278
+ decimals: 18
279
+ },
280
+ rpcUrls: {
281
+ alchemy: alchemyRpcUrls.optimismKovan,
282
+ infura: infuraRpcUrls.optimismKovan,
283
+ default: ['https://kovan.optimism.io']
284
+ },
285
+ blockExplorers: {
286
+ etherscan: etherscanBlockExplorers.optimismKovan,
287
+ default: etherscanBlockExplorers.optimismKovan
288
+ },
289
+ testnet: true
290
+ },
291
+ polygon: {
292
+ id: chainId.polygon,
293
+ name: 'Polygon Mainnet',
294
+ nativeCurrency: {
295
+ name: 'MATIC',
296
+ symbol: 'MATIC',
297
+ decimals: 18
298
+ },
299
+ rpcUrls: {
300
+ alchemy: alchemyRpcUrls.polygon,
301
+ infura: infuraRpcUrls.polygon,
302
+ default: ['https://polygon-rpc.com', 'https://rpc-mainnet.matic.network', 'https://matic-mainnet.chainstacklabs.com', 'https://rpc-mainnet.maticvigil.com', 'https://rpc-mainnet.matic.quiknode.pro', 'https://matic-mainnet-full-rpc.bwarelabs.com']
303
+ },
304
+ blockExplorers: {
305
+ etherscan: etherscanBlockExplorers.polygon,
306
+ default: etherscanBlockExplorers.polygon
307
+ }
308
+ },
309
+ polygonMumbai: {
310
+ id: chainId.polygonMumbai,
311
+ name: 'Mumbai',
312
+ nativeCurrency: {
313
+ name: 'MATIC',
314
+ symbol: 'MATIC',
315
+ decimals: 18
316
+ },
317
+ rpcUrls: {
318
+ alchemy: alchemyRpcUrls.polygonMumbai,
319
+ infura: infuraRpcUrls.polygonMumbai,
320
+ default: ['https://matic-mumbai.chainstacklabs.com', 'https://rpc-mumbai.maticvigil.com', 'https://matic-testnet-archive-rpc.bwarelabs.com']
321
+ },
322
+ blockExplorers: {
323
+ etherscan: etherscanBlockExplorers.polygonMumbai,
324
+ default: etherscanBlockExplorers.polygonMumbai
325
+ },
326
+ testnet: true
327
+ },
328
+ arbitrum: {
329
+ id: chainId.arbitrum,
330
+ name: 'Arbitrum One',
331
+ nativeCurrency: {
332
+ name: 'Ether',
333
+ symbol: 'AETH',
334
+ decimals: 18
335
+ },
336
+ rpcUrls: {
337
+ alchemy: alchemyRpcUrls.arbitrum,
338
+ infura: infuraRpcUrls.arbitrum,
339
+ default: ['https://arb1.arbitrum.io/rpc']
340
+ },
341
+ blockExplorers: {
342
+ etherscan: etherscanBlockExplorers.arbitrum,
343
+ default: [etherscanBlockExplorers.arbitrum, {
344
+ name: 'Arbitrum Explorer',
345
+ url: 'https://explorer.arbitrum.io'
346
+ }]
347
+ }
348
+ },
349
+ arbitrumRinkeby: {
350
+ id: chainId.arbitrumRinkeby,
351
+ name: 'Arbitrum Rinkeby',
352
+ nativeCurrency: {
353
+ name: 'Arbitrum Rinkeby Ether',
354
+ symbol: 'ARETH',
355
+ decimals: 18
356
+ },
357
+ rpcUrls: {
358
+ alchemy: alchemyRpcUrls.arbitrumRinkeby,
359
+ infura: infuraRpcUrls.arbitrumRinkeby,
360
+ default: ['https://rinkeby.arbitrum.io/rpc']
361
+ },
362
+ blockExplorers: {
363
+ etherscan: etherscanBlockExplorers.arbitrumRinkeby,
364
+ default: [etherscanBlockExplorers.arbitrumRinkeby, {
365
+ name: 'Arbitrum Explorer',
366
+ url: 'https://rinkeby-explorer.arbitrum.io'
367
+ }]
368
+ },
369
+ testnet: true
370
+ },
371
+ localhost: {
372
+ id: chainId.localhost,
373
+ name: 'Localhost',
374
+ rpcUrls: {
375
+ default: 'http://127.0.0.1:8545'
376
+ }
377
+ },
378
+ hardhat: {
379
+ id: chainId.hardhat,
380
+ name: 'Hardhat',
381
+ rpcUrls: {
382
+ default: 'http://127.0.0.1:8545'
383
+ }
384
+ }
385
+ };
386
+ const allChains = Object.values(chain);
387
+ const defaultChains = [chain.mainnet, chain.ropsten, chain.rinkeby, chain.goerli, chain.kovan];
388
+
389
+ function normalizeChainId(chainId) {
390
+ if (typeof chainId === 'string') return Number.parseInt(chainId, chainId.trim().substring(0, 2) === '0x' ? 16 : 10);
391
+ return chainId;
392
+ }
393
+
394
+ class AddChainError extends Error {
395
+ constructor() {
396
+ super(...arguments);
397
+
398
+ _defineProperty(this, "name", 'AddChainError');
399
+
400
+ _defineProperty(this, "message", 'Error adding chain');
401
+ }
402
+
403
+ }
404
+ class ChainNotConfiguredError extends Error {
405
+ constructor() {
406
+ super(...arguments);
407
+
408
+ _defineProperty(this, "name", 'ChainNotConfigured');
409
+
410
+ _defineProperty(this, "message", 'Chain not configured');
411
+ }
412
+
413
+ }
414
+ class ConnectorAlreadyConnectedError extends Error {
415
+ constructor() {
416
+ super(...arguments);
417
+
418
+ _defineProperty(this, "name", 'ConnectorAlreadyConnectedError');
419
+
420
+ _defineProperty(this, "message", 'Connector already connected');
421
+ }
422
+
423
+ }
424
+ class ConnectorNotFoundError extends Error {
425
+ constructor() {
426
+ super(...arguments);
427
+
428
+ _defineProperty(this, "name", 'ConnectorNotFoundError');
429
+
430
+ _defineProperty(this, "message", 'Connector not found');
431
+ }
432
+
433
+ }
434
+ class SwitchChainError extends Error {
435
+ constructor() {
436
+ super(...arguments);
437
+
438
+ _defineProperty(this, "name", 'SwitchChainError');
439
+
440
+ _defineProperty(this, "message", 'Error switching chain');
441
+ }
442
+
443
+ }
444
+ class SwitchChainNotSupportedError extends Error {
445
+ constructor() {
446
+ super(...arguments);
447
+
448
+ _defineProperty(this, "name", 'SwitchChainNotSupportedError');
449
+
450
+ _defineProperty(this, "message", 'Switch chain not supported by connector');
451
+ }
452
+
453
+ }
454
+ class UserRejectedRequestError extends Error {
455
+ constructor() {
456
+ super(...arguments);
457
+
458
+ _defineProperty(this, "name", 'UserRejectedRequestError');
459
+
460
+ _defineProperty(this, "message", 'User rejected request');
461
+ }
462
+
463
+ }
464
+
465
+ class Connector extends EventEmitter {
466
+ /** Unique connector id */
467
+
468
+ /** Connector name */
469
+
470
+ /** Chains connector supports */
471
+
472
+ /** Options to use with connector */
473
+
474
+ /** Whether connector is usable */
475
+ constructor(_ref) {
476
+ let {
477
+ chains = defaultChains,
478
+ options
479
+ } = _ref;
480
+ super();
481
+
482
+ _defineProperty(this, "id", void 0);
483
+
484
+ _defineProperty(this, "name", void 0);
485
+
486
+ _defineProperty(this, "chains", void 0);
487
+
488
+ _defineProperty(this, "options", void 0);
489
+
490
+ _defineProperty(this, "ready", void 0);
491
+
492
+ this.chains = chains;
493
+ this.options = options;
494
+ }
495
+
496
+ getBlockExplorerUrls(chain) {
497
+ var _chain$blockExplorers;
498
+
499
+ const blockExplorer = (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default;
500
+ if (Array.isArray(blockExplorer)) return blockExplorer.map(x => x.url);
501
+ if (blockExplorer !== null && blockExplorer !== void 0 && blockExplorer.url) return [blockExplorer.url];
502
+ return [];
503
+ }
504
+
505
+ getRpcUrls(chain) {
506
+ return typeof chain.rpcUrls.default === 'string' ? [chain.rpcUrls.default] : chain.rpcUrls.default;
507
+ }
508
+
509
+ isChainUnsupported(chainId) {
510
+ return !this.chains.some(x => x.id === chainId);
511
+ }
512
+
513
+ }
514
+
515
+ export { AddChainError as A, Connector as C, SwitchChainError as S, UserRejectedRequestError as U, _defineProperty as _, _classPrivateFieldInitSpec as a, ConnectorNotFoundError as b, _classPrivateFieldSet as c, _classPrivateFieldGet as d, allChains as e, ChainNotConfiguredError as f, ConnectorAlreadyConnectedError as g, SwitchChainNotSupportedError as h, alchemyRpcUrls as i, chain as j, chainId as k, defaultChains as l, etherscanBlockExplorers as m, normalizeChainId as n, infuraRpcUrls as o, _checkPrivateRedeclaration as p };