@wagmi/core 0.4.0-test.2 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
- package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
- package/chains/dist/wagmi-core-chains.esm.js +2 -2
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +9 -7
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +9 -7
- package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +9 -7
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +7 -5
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +7 -5
- package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +7 -5
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +12 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +12 -8
- package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +7 -7
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +19 -18
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +19 -18
- package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +19 -18
- package/dist/base-2d484f6c.cjs.prod.js +329 -0
- package/dist/base-e66f9622.esm.js +303 -0
- package/dist/base-e71ae4b2.cjs.dev.js +329 -0
- package/dist/{chains-7e369752.cjs.dev.js → chains-865492ea.cjs.prod.js} +79 -16
- package/dist/{chains-fa406563.esm.js → chains-c389721d.esm.js} +79 -16
- package/dist/{chains-d045862c.cjs.prod.js → chains-d970ee8d.cjs.dev.js} +79 -16
- package/dist/{client-42cf11b7.cjs.dev.js → client-1feb9121.cjs.prod.js} +29 -46
- package/dist/{client-ed3aaa6a.cjs.prod.js → client-53f2119c.cjs.dev.js} +29 -46
- package/dist/{client-60ee0298.esm.js → client-ffba0e25.esm.js} +29 -46
- package/dist/declarations/src/actions/accounts/getAccount.d.ts +31 -2
- package/dist/declarations/src/actions/accounts/getNetwork.d.ts +1 -2
- package/dist/declarations/src/actions/accounts/signTypedData.d.ts +17 -15
- package/dist/declarations/src/actions/accounts/watchAccount.d.ts +9 -1
- package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +8 -1
- package/dist/declarations/src/actions/contracts/index.d.ts +5 -3
- package/dist/declarations/src/actions/contracts/multicall.d.ts +21 -0
- package/dist/declarations/src/actions/contracts/readContract.d.ts +7 -4
- package/dist/declarations/src/actions/contracts/readContracts.d.ts +19 -0
- package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +3 -3
- package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +2 -3
- package/dist/declarations/src/actions/contracts/watchReadContracts.d.ts +6 -0
- package/dist/declarations/src/actions/contracts/writeContract.d.ts +10 -4
- package/dist/declarations/src/actions/index.d.ts +1 -1
- package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +6 -1
- package/dist/declarations/src/client.d.ts +6 -11
- package/dist/declarations/src/connectors/base.d.ts +4 -3
- package/dist/declarations/src/connectors/mock/connector.d.ts +2 -9
- package/dist/declarations/src/connectors/mock/provider.d.ts +2 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +5 -4
- package/dist/declarations/src/constants/index.d.ts +2 -1
- package/dist/declarations/src/constants/multicall.d.ts +25 -0
- package/dist/declarations/src/constants/rpcs.d.ts +3 -1
- package/dist/declarations/src/errors.d.ts +27 -5
- package/dist/declarations/src/index.d.ts +5 -5
- package/dist/declarations/src/providers/alchemy.d.ts +2 -2
- package/dist/declarations/src/providers/infura.d.ts +2 -2
- package/dist/declarations/src/providers/jsonRpc.d.ts +2 -2
- package/dist/declarations/src/providers/public.d.ts +2 -2
- package/dist/declarations/src/types/index.d.ts +17 -5
- package/dist/declarations/src/utils/configureChains.d.ts +10 -4
- package/dist/declarations/src/utils/normalizeChainId.d.ts +1 -1
- package/dist/{rpcs-9c4eb960.cjs.dev.js → rpcs-1fd0a12f.cjs.prod.js} +14 -0
- package/dist/{rpcs-7cfbd91c.esm.js → rpcs-b73a8f60.esm.js} +14 -1
- package/dist/{rpcs-b3c52116.cjs.prod.js → rpcs-f1d24f0e.cjs.dev.js} +14 -0
- package/dist/wagmi-core.cjs.dev.js +611 -234
- package/dist/wagmi-core.cjs.prod.js +611 -234
- package/dist/wagmi-core.esm.js +608 -242
- package/package.json +15 -3
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +1 -1
- package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +1 -1
- package/providers/infura/dist/wagmi-core-providers-infura.esm.js +1 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.dev.js +3 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.cjs.prod.js +3 -1
- package/providers/jsonRpc/dist/wagmi-core-providers-jsonRpc.esm.js +3 -1
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.d.ts +0 -1
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.dev.js +0 -200
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.js +0 -7
- package/connectors/injected/dist/wagmi-core-connectors-injected.cjs.prod.js +0 -200
- package/connectors/injected/dist/wagmi-core-connectors-injected.esm.js +0 -196
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.d.ts +0 -11
- package/connectors/walletLink/dist/wagmi-core-connectors-walletLink.cjs.js +0 -16
- package/dist/base-7f682723.cjs.prod.js +0 -623
- package/dist/base-ae774f26.cjs.dev.js +0 -623
- package/dist/base-c546f171.esm.js +0 -603
- package/dist/declarations/src/utils/eventemitter.d.ts +0 -135
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
import { d as defaultChains } from './chains-fa406563.esm.js';
|
|
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 _classPrivateMethodInitSpec(obj, privateSet) {
|
|
10
|
-
_checkPrivateRedeclaration(obj, privateSet);
|
|
11
|
-
privateSet.add(obj);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
15
|
-
_checkPrivateRedeclaration(obj, privateMap);
|
|
16
|
-
privateMap.set(obj, value);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _defineProperty(obj, key, value) {
|
|
20
|
-
if (key in obj) {
|
|
21
|
-
Object.defineProperty(obj, key, {
|
|
22
|
-
value: value,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
obj[key] = value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
35
|
-
if (descriptor.get) {
|
|
36
|
-
return descriptor.get.call(receiver);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return descriptor.value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
43
|
-
if (!privateMap.has(receiver)) {
|
|
44
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return privateMap.get(receiver);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _classPrivateFieldGet(receiver, privateMap) {
|
|
51
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
52
|
-
return _classApplyDescriptorGet(receiver, descriptor);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) {
|
|
56
|
-
if (!privateSet.has(receiver)) {
|
|
57
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return fn;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
64
|
-
if (descriptor.set) {
|
|
65
|
-
descriptor.set.call(receiver, value);
|
|
66
|
-
} else {
|
|
67
|
-
if (!descriptor.writable) {
|
|
68
|
-
throw new TypeError("attempted to set read only private field");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
descriptor.value = value;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
76
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
77
|
-
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
78
|
-
return value;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function normalizeChainId(chainId) {
|
|
82
|
-
if (typeof chainId === 'string') return Number.parseInt(chainId, chainId.trim().substring(0, 2) === '0x' ? 16 : 10);
|
|
83
|
-
return chainId;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Error subclass implementing JSON RPC 2.0 errors and Ethereum RPC errors per EIP-1474.
|
|
88
|
-
* @see https://eips.ethereum.org/EIPS/eip-1474
|
|
89
|
-
*/
|
|
90
|
-
class RpcError extends Error {
|
|
91
|
-
constructor(
|
|
92
|
-
/** Number error code */
|
|
93
|
-
code,
|
|
94
|
-
/** Human-readable string */
|
|
95
|
-
message,
|
|
96
|
-
/** Low-level error */
|
|
97
|
-
internal,
|
|
98
|
-
/** Other useful information about error */
|
|
99
|
-
data) {
|
|
100
|
-
if (!Number.isInteger(code)) throw new Error('"code" must be an integer.');
|
|
101
|
-
if (!message || typeof message !== 'string') throw new Error('"message" must be a nonempty string.');
|
|
102
|
-
super(message);
|
|
103
|
-
|
|
104
|
-
_defineProperty(this, "code", void 0);
|
|
105
|
-
|
|
106
|
-
_defineProperty(this, "data", void 0);
|
|
107
|
-
|
|
108
|
-
_defineProperty(this, "internal", void 0);
|
|
109
|
-
|
|
110
|
-
this.code = code;
|
|
111
|
-
this.data = data;
|
|
112
|
-
this.internal = internal;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Error subclass implementing Ethereum Provider errors per EIP-1193.
|
|
118
|
-
* @see https://eips.ethereum.org/EIPS/eip-1193
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
class ProviderRpcError extends RpcError {
|
|
122
|
-
/**
|
|
123
|
-
* Create an Ethereum Provider JSON-RPC error.
|
|
124
|
-
* `code` must be an integer in the 1000 <= 4999 range.
|
|
125
|
-
*/
|
|
126
|
-
constructor(
|
|
127
|
-
/**
|
|
128
|
-
* Number error code
|
|
129
|
-
* @see https://eips.ethereum.org/EIPS/eip-1193#error-standards
|
|
130
|
-
*/
|
|
131
|
-
code,
|
|
132
|
-
/** Human-readable string */
|
|
133
|
-
message,
|
|
134
|
-
/** Low-level error */
|
|
135
|
-
internal,
|
|
136
|
-
/** Other useful information about error */
|
|
137
|
-
data) {
|
|
138
|
-
if (!(Number.isInteger(code) && code >= 1000 && code <= 4999)) throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
|
|
139
|
-
super(code, message, internal, data);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
class AddChainError extends Error {
|
|
144
|
-
constructor() {
|
|
145
|
-
super(...arguments);
|
|
146
|
-
|
|
147
|
-
_defineProperty(this, "name", 'AddChainError');
|
|
148
|
-
|
|
149
|
-
_defineProperty(this, "message", 'Error adding chain');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
class ChainNotConfiguredError extends Error {
|
|
154
|
-
constructor() {
|
|
155
|
-
super(...arguments);
|
|
156
|
-
|
|
157
|
-
_defineProperty(this, "name", 'ChainNotConfigured');
|
|
158
|
-
|
|
159
|
-
_defineProperty(this, "message", 'Chain not configured');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
class ConnectorAlreadyConnectedError extends Error {
|
|
164
|
-
constructor() {
|
|
165
|
-
super(...arguments);
|
|
166
|
-
|
|
167
|
-
_defineProperty(this, "name", 'ConnectorAlreadyConnectedError');
|
|
168
|
-
|
|
169
|
-
_defineProperty(this, "message", 'Connector already connected');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
class ConnectorNotFoundError extends Error {
|
|
174
|
-
constructor() {
|
|
175
|
-
super(...arguments);
|
|
176
|
-
|
|
177
|
-
_defineProperty(this, "name", 'ConnectorNotFoundError');
|
|
178
|
-
|
|
179
|
-
_defineProperty(this, "message", 'Connector not found');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
class SwitchChainError extends ProviderRpcError {
|
|
184
|
-
constructor(error) {
|
|
185
|
-
super(4902, 'Error switching chain', error);
|
|
186
|
-
|
|
187
|
-
_defineProperty(this, "name", 'SwitchChainError');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
class SwitchChainNotSupportedError extends Error {
|
|
192
|
-
constructor() {
|
|
193
|
-
super(...arguments);
|
|
194
|
-
|
|
195
|
-
_defineProperty(this, "name", 'SwitchChainNotSupportedError');
|
|
196
|
-
|
|
197
|
-
_defineProperty(this, "message", 'Switch chain not supported by connector');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
class UserRejectedRequestError extends ProviderRpcError {
|
|
202
|
-
constructor(error) {
|
|
203
|
-
super(4001, 'User rejected request', error);
|
|
204
|
-
|
|
205
|
-
_defineProperty(this, "name", 'UserRejectedRequestError');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
class ResourceUnavailableError extends RpcError {
|
|
210
|
-
constructor(error) {
|
|
211
|
-
super(-32002, 'Resource unavailable', error);
|
|
212
|
-
|
|
213
|
-
_defineProperty(this, "name", 'ResourceUnavailable');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const has = Object.prototype.hasOwnProperty;
|
|
219
|
-
let prefix = '~';
|
|
220
|
-
/**
|
|
221
|
-
* Constructor to create a storage for our `EE` objects.
|
|
222
|
-
* An `Events` instance is a plain object whose properties are event names.
|
|
223
|
-
*
|
|
224
|
-
* @constructor
|
|
225
|
-
* @private
|
|
226
|
-
*/
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
228
|
-
|
|
229
|
-
function Events() {} //
|
|
230
|
-
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
231
|
-
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
232
|
-
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
233
|
-
// character to make sure that the built-in object properties are not
|
|
234
|
-
// overridden or used as an attack vector.
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (Object.create) {
|
|
239
|
-
Events.prototype = Object.create(null); //
|
|
240
|
-
// This hack is needed because the `__proto__` property is still inherited in
|
|
241
|
-
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
if (!new Events().__proto__) prefix = false;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Representation of a single event listener.
|
|
248
|
-
*
|
|
249
|
-
* @param {Function} fn The listener function.
|
|
250
|
-
* @param {*} context The context to invoke the listener with.
|
|
251
|
-
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
252
|
-
* @constructor
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
function EE(fn, context, once) {
|
|
258
|
-
this.fn = fn;
|
|
259
|
-
this.context = context;
|
|
260
|
-
this.once = once || false;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Add a listener for a given event.
|
|
264
|
-
*
|
|
265
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
266
|
-
* @param {(String|Symbol)} event The event name.
|
|
267
|
-
* @param {Function} fn The listener function.
|
|
268
|
-
* @param {*} context The context to invoke the listener with.
|
|
269
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
270
|
-
* @returns {EventEmitter}
|
|
271
|
-
* @private
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
function addListener(emitter, event, fn, context, once) {
|
|
276
|
-
if (typeof fn !== 'function') {
|
|
277
|
-
throw new TypeError('The listener must be a function');
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
var listener = new EE(fn, context || emitter, once),
|
|
281
|
-
evt = prefix ? prefix + event : event;
|
|
282
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);else emitter._events[evt] = [emitter._events[evt], listener];
|
|
283
|
-
return emitter;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Clear event by name.
|
|
287
|
-
*
|
|
288
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
289
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
290
|
-
* @private
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
function clearEvent(emitter, evt) {
|
|
295
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();else delete emitter._events[evt];
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
299
|
-
* `EventEmitter` interface.
|
|
300
|
-
*
|
|
301
|
-
* @constructor
|
|
302
|
-
* @public
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
function EventEmitter() {
|
|
307
|
-
this._events = new Events();
|
|
308
|
-
this._eventsCount = 0;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Return an array listing the events for which the emitter has registered
|
|
312
|
-
* listeners.
|
|
313
|
-
*
|
|
314
|
-
* @returns {Array}
|
|
315
|
-
* @public
|
|
316
|
-
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
320
|
-
var names = [],
|
|
321
|
-
events,
|
|
322
|
-
name;
|
|
323
|
-
if (this._eventsCount === 0) return names;
|
|
324
|
-
|
|
325
|
-
for (name in events = this._events) {
|
|
326
|
-
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (Object.getOwnPropertySymbols) {
|
|
330
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return names;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Return the listeners registered for a given event.
|
|
337
|
-
*
|
|
338
|
-
* @param {(String|Symbol)} event The event name.
|
|
339
|
-
* @returns {Array} The registered listeners.
|
|
340
|
-
* @public
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
345
|
-
var evt = prefix ? prefix + event : event,
|
|
346
|
-
handlers = this._events[evt];
|
|
347
|
-
if (!handlers) return [];
|
|
348
|
-
if (handlers.fn) return [handlers.fn];
|
|
349
|
-
|
|
350
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
351
|
-
ee[i] = handlers[i].fn;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return ee;
|
|
355
|
-
};
|
|
356
|
-
/**
|
|
357
|
-
* Return the number of listeners listening to a given event.
|
|
358
|
-
*
|
|
359
|
-
* @param {(String|Symbol)} event The event name.
|
|
360
|
-
* @returns {Number} The number of listeners.
|
|
361
|
-
* @public
|
|
362
|
-
*/
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
366
|
-
var evt = prefix ? prefix + event : event,
|
|
367
|
-
listeners = this._events[evt];
|
|
368
|
-
if (!listeners) return 0;
|
|
369
|
-
if (listeners.fn) return 1;
|
|
370
|
-
return listeners.length;
|
|
371
|
-
};
|
|
372
|
-
/**
|
|
373
|
-
* Calls each of the listeners registered for a given event.
|
|
374
|
-
*
|
|
375
|
-
* @param {(String|Symbol)} event The event name.
|
|
376
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
377
|
-
* @public
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
382
|
-
var evt = prefix ? prefix + event : event;
|
|
383
|
-
if (!this._events[evt]) return false;
|
|
384
|
-
var listeners = this._events[evt],
|
|
385
|
-
len = arguments.length,
|
|
386
|
-
args,
|
|
387
|
-
i;
|
|
388
|
-
|
|
389
|
-
if (listeners.fn) {
|
|
390
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
391
|
-
|
|
392
|
-
switch (len) {
|
|
393
|
-
case 1:
|
|
394
|
-
return listeners.fn.call(listeners.context), true;
|
|
395
|
-
|
|
396
|
-
case 2:
|
|
397
|
-
return listeners.fn.call(listeners.context, a1), true;
|
|
398
|
-
|
|
399
|
-
case 3:
|
|
400
|
-
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
401
|
-
|
|
402
|
-
case 4:
|
|
403
|
-
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
404
|
-
|
|
405
|
-
case 5:
|
|
406
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
407
|
-
|
|
408
|
-
case 6:
|
|
409
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
for (i = 1, args = new Array(len - 1); i < len; i++) {
|
|
413
|
-
args[i - 1] = arguments[i];
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
listeners.fn.apply(listeners.context, args);
|
|
417
|
-
} else {
|
|
418
|
-
var length = listeners.length,
|
|
419
|
-
j;
|
|
420
|
-
|
|
421
|
-
for (i = 0; i < length; i++) {
|
|
422
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
423
|
-
|
|
424
|
-
switch (len) {
|
|
425
|
-
case 1:
|
|
426
|
-
listeners[i].fn.call(listeners[i].context);
|
|
427
|
-
break;
|
|
428
|
-
|
|
429
|
-
case 2:
|
|
430
|
-
listeners[i].fn.call(listeners[i].context, a1);
|
|
431
|
-
break;
|
|
432
|
-
|
|
433
|
-
case 3:
|
|
434
|
-
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
435
|
-
break;
|
|
436
|
-
|
|
437
|
-
case 4:
|
|
438
|
-
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
439
|
-
break;
|
|
440
|
-
|
|
441
|
-
default:
|
|
442
|
-
if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
|
|
443
|
-
args[j - 1] = arguments[j];
|
|
444
|
-
}
|
|
445
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
return true;
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Add a listener for a given event.
|
|
454
|
-
*
|
|
455
|
-
* @param {(String|Symbol)} event The event name.
|
|
456
|
-
* @param {Function} fn The listener function.
|
|
457
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
458
|
-
* @returns {EventEmitter} `this`.
|
|
459
|
-
* @public
|
|
460
|
-
*/
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
464
|
-
return addListener(this, event, fn, context, false);
|
|
465
|
-
};
|
|
466
|
-
/**
|
|
467
|
-
* Add a one-time listener for a given event.
|
|
468
|
-
*
|
|
469
|
-
* @param {(String|Symbol)} event The event name.
|
|
470
|
-
* @param {Function} fn The listener function.
|
|
471
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
472
|
-
* @returns {EventEmitter} `this`.
|
|
473
|
-
* @public
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
478
|
-
return addListener(this, event, fn, context, true);
|
|
479
|
-
};
|
|
480
|
-
/**
|
|
481
|
-
* Remove the listeners of a given event.
|
|
482
|
-
*
|
|
483
|
-
* @param {(String|Symbol)} event The event name.
|
|
484
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
485
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
486
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
487
|
-
* @returns {EventEmitter} `this`.
|
|
488
|
-
* @public
|
|
489
|
-
*/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
493
|
-
var evt = prefix ? prefix + event : event;
|
|
494
|
-
if (!this._events[evt]) return this;
|
|
495
|
-
|
|
496
|
-
if (!fn) {
|
|
497
|
-
clearEvent(this, evt);
|
|
498
|
-
return this;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
var listeners = this._events[evt];
|
|
502
|
-
|
|
503
|
-
if (listeners.fn) {
|
|
504
|
-
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
505
|
-
clearEvent(this, evt);
|
|
506
|
-
}
|
|
507
|
-
} else {
|
|
508
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
509
|
-
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
510
|
-
events.push(listeners[i]);
|
|
511
|
-
}
|
|
512
|
-
} //
|
|
513
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
514
|
-
//
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;else clearEvent(this, evt);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
return this;
|
|
521
|
-
};
|
|
522
|
-
/**
|
|
523
|
-
* Remove all listeners, or those of the specified event.
|
|
524
|
-
*
|
|
525
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
526
|
-
* @returns {EventEmitter} `this`.
|
|
527
|
-
* @public
|
|
528
|
-
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
532
|
-
var evt;
|
|
533
|
-
|
|
534
|
-
if (event) {
|
|
535
|
-
evt = prefix ? prefix + event : event;
|
|
536
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
537
|
-
} else {
|
|
538
|
-
this._events = new Events();
|
|
539
|
-
this._eventsCount = 0;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return this;
|
|
543
|
-
}; //
|
|
544
|
-
// Alias methods names because people roll like that.
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
549
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on; //
|
|
550
|
-
// Expose the prefix.
|
|
551
|
-
//
|
|
552
|
-
|
|
553
|
-
EventEmitter.prefixed = prefix;
|
|
554
|
-
|
|
555
|
-
class Connector extends EventEmitter {
|
|
556
|
-
/** Unique connector id */
|
|
557
|
-
|
|
558
|
-
/** Connector name */
|
|
559
|
-
|
|
560
|
-
/** Chains connector supports */
|
|
561
|
-
|
|
562
|
-
/** Options to use with connector */
|
|
563
|
-
|
|
564
|
-
/** Whether connector is usable */
|
|
565
|
-
constructor(_ref) {
|
|
566
|
-
let {
|
|
567
|
-
chains = defaultChains,
|
|
568
|
-
options
|
|
569
|
-
} = _ref;
|
|
570
|
-
super();
|
|
571
|
-
|
|
572
|
-
_defineProperty(this, "id", void 0);
|
|
573
|
-
|
|
574
|
-
_defineProperty(this, "name", void 0);
|
|
575
|
-
|
|
576
|
-
_defineProperty(this, "chains", void 0);
|
|
577
|
-
|
|
578
|
-
_defineProperty(this, "options", void 0);
|
|
579
|
-
|
|
580
|
-
_defineProperty(this, "ready", void 0);
|
|
581
|
-
|
|
582
|
-
this.chains = chains;
|
|
583
|
-
this.options = options;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
getBlockExplorerUrls(chain) {
|
|
587
|
-
var _chain$blockExplorers;
|
|
588
|
-
|
|
589
|
-
const {
|
|
590
|
-
default: blockExplorer,
|
|
591
|
-
...blockExplorers
|
|
592
|
-
} = (_chain$blockExplorers = chain.blockExplorers) !== null && _chain$blockExplorers !== void 0 ? _chain$blockExplorers : {};
|
|
593
|
-
if (blockExplorer) return [blockExplorer.url, ...Object.values(blockExplorers).map(x => x.url)];
|
|
594
|
-
return [];
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
isChainUnsupported(chainId) {
|
|
598
|
-
return !this.chains.some(x => x.id === chainId);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
export { AddChainError as A, ConnectorAlreadyConnectedError as C, EventEmitter as E, ProviderRpcError as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _, ConnectorNotFoundError as a, Connector as b, ChainNotConfiguredError as c, RpcError as d, SwitchChainError as e, _defineProperty as f, _classPrivateFieldInitSpec as g, _classPrivateFieldGet as h, _classPrivateFieldSet as i, _classPrivateMethodGet as j, normalizeChainId as n };
|