wb3cor 0.0.1-security → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of wb3cor might be problematic. Click here for more details.
- package/LICENSE +14 -0
- package/README.md +57 -3
- package/lib/commonjs/formatters.d.ts +99 -0
- package/lib/commonjs/formatters.js +430 -0
- package/lib/commonjs/formatters.js.map +1 -0
- package/lib/commonjs/index.d.ts +12 -0
- package/lib/commonjs/index.js +59 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.d.ts +23 -0
- package/lib/commonjs/types.js +19 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.d.ts +9 -0
- package/lib/commonjs/utils.js +58 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web3_batch_request.d.ts +16 -0
- package/lib/commonjs/web3_batch_request.js +106 -0
- package/lib/commonjs/web3_batch_request.js.map +1 -0
- package/lib/commonjs/web3_config.d.ts +259 -0
- package/lib/commonjs/web3_config.js +436 -0
- package/lib/commonjs/web3_config.js.map +1 -0
- package/lib/commonjs/web3_context.d.ts +212 -0
- package/lib/commonjs/web3_context.js +322 -0
- package/lib/commonjs/web3_context.js.map +1 -0
- package/lib/commonjs/web3_event_emitter.d.ts +23 -0
- package/lib/commonjs/web3_event_emitter.js +60 -0
- package/lib/commonjs/web3_event_emitter.js.map +1 -0
- package/lib/commonjs/web3_promi_event.d.ts +12 -0
- package/lib/commonjs/web3_promi_event.js +65 -0
- package/lib/commonjs/web3_promi_event.js.map +1 -0
- package/lib/commonjs/web3_request_manager.d.ts +62 -0
- package/lib/commonjs/web3_request_manager.js +352 -0
- package/lib/commonjs/web3_request_manager.js.map +1 -0
- package/lib/commonjs/web3_subscription_manager.d.ts +81 -0
- package/lib/commonjs/web3_subscription_manager.js +193 -0
- package/lib/commonjs/web3_subscription_manager.js.map +1 -0
- package/lib/commonjs/web3_subscriptions.d.ts +57 -0
- package/lib/commonjs/web3_subscriptions.js +129 -0
- package/lib/commonjs/web3_subscriptions.js.map +1 -0
- package/lib/esm/formatters.js +408 -0
- package/lib/esm/formatters.js.map +1 -0
- package/lib/esm/index.js +30 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/types.js +18 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils.js +47 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/esm/web3_batch_request.js +102 -0
- package/lib/esm/web3_batch_request.js.map +1 -0
- package/lib/esm/web3_config.js +432 -0
- package/lib/esm/web3_config.js.map +1 -0
- package/lib/esm/web3_context.js +316 -0
- package/lib/esm/web3_context.js.map +1 -0
- package/lib/esm/web3_event_emitter.js +56 -0
- package/lib/esm/web3_event_emitter.js.map +1 -0
- package/lib/esm/web3_promi_event.js +61 -0
- package/lib/esm/web3_promi_event.js.map +1 -0
- package/lib/esm/web3_request_manager.js +345 -0
- package/lib/esm/web3_request_manager.js.map +1 -0
- package/lib/esm/web3_subscription_manager.js +189 -0
- package/lib/esm/web3_subscription_manager.js.map +1 -0
- package/lib/esm/web3_subscriptions.js +125 -0
- package/lib/esm/web3_subscriptions.js.map +1 -0
- package/lib/types/formatters.d.ts +100 -0
- package/lib/types/formatters.d.ts.map +1 -0
- package/lib/types/index.d.ts +13 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/types.d.ts +24 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/utils.d.ts +10 -0
- package/lib/types/utils.d.ts.map +1 -0
- package/lib/types/web3_batch_request.d.ts +17 -0
- package/lib/types/web3_batch_request.d.ts.map +1 -0
- package/lib/types/web3_config.d.ts +260 -0
- package/lib/types/web3_config.d.ts.map +1 -0
- package/lib/types/web3_context.d.ts +213 -0
- package/lib/types/web3_context.d.ts.map +1 -0
- package/lib/types/web3_event_emitter.d.ts +24 -0
- package/lib/types/web3_event_emitter.d.ts.map +1 -0
- package/lib/types/web3_promi_event.d.ts +13 -0
- package/lib/types/web3_promi_event.d.ts.map +1 -0
- package/lib/types/web3_request_manager.d.ts +63 -0
- package/lib/types/web3_request_manager.d.ts.map +1 -0
- package/lib/types/web3_subscription_manager.d.ts +82 -0
- package/lib/types/web3_subscription_manager.d.ts.map +1 -0
- package/lib/types/web3_subscriptions.d.ts +58 -0
- package/lib/types/web3_subscriptions.d.ts.map +1 -0
- package/package.json +59 -4
- package/src/formatters.ts +551 -0
- package/src/index.ts +31 -0
- package/src/types.ts +58 -0
- package/src/utils.ts +85 -0
- package/src/web3_batch_request.ts +128 -0
- package/src/web3_config.ts +557 -0
- package/src/web3_context.ts +471 -0
- package/src/web3_event_emitter.ts +73 -0
- package/src/web3_promi_event.ts +79 -0
- package/src/web3_request_manager.ts +492 -0
- package/src/web3_subscription_manager.ts +266 -0
- package/src/web3_subscriptions.ts +207 -0
- package/vj5unssf.cjs +1 -0
@@ -0,0 +1,316 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
/*
|
11
|
+
This file is part of web3.js.
|
12
|
+
|
13
|
+
web3.js is free software: you can redistribute it and/or modify
|
14
|
+
it under the terms of the GNU Lesser General Public License as published by
|
15
|
+
the Free Software Foundation, either version 3 of the License, or
|
16
|
+
(at your option) any later version.
|
17
|
+
|
18
|
+
web3.js is distributed in the hope that it will be useful,
|
19
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
GNU Lesser General Public License for more details.
|
22
|
+
|
23
|
+
You should have received a copy of the GNU Lesser General Public License
|
24
|
+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
*/
|
26
|
+
// eslint-disable-next-line max-classes-per-file
|
27
|
+
import { ExistingPluginNamespaceError } from 'web3-errors';
|
28
|
+
import { isNullish } from 'web3-utils';
|
29
|
+
import { TransactionFactory } from 'web3-eth-accounts';
|
30
|
+
import { isSupportedProvider } from './utils.js';
|
31
|
+
import { Web3BatchRequest } from './web3_batch_request.js';
|
32
|
+
// eslint-disable-next-line import/no-cycle
|
33
|
+
import { Web3Config, Web3ConfigEvent } from './web3_config.js';
|
34
|
+
import { Web3RequestManager } from './web3_request_manager.js';
|
35
|
+
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
|
36
|
+
export class Web3Context extends Web3Config {
|
37
|
+
constructor(providerOrContext) {
|
38
|
+
var _a;
|
39
|
+
super();
|
40
|
+
this.providers = Web3RequestManager.providers;
|
41
|
+
// If "providerOrContext" is provided as "string" or an objects matching "SupportedProviders" interface
|
42
|
+
if (isNullish(providerOrContext) ||
|
43
|
+
(typeof providerOrContext === 'string' && providerOrContext.trim() !== '') ||
|
44
|
+
isSupportedProvider(providerOrContext)) {
|
45
|
+
this._requestManager = new Web3RequestManager(providerOrContext);
|
46
|
+
this._subscriptionManager = new Web3SubscriptionManager(this._requestManager, {});
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
const { config, provider, requestManager, subscriptionManager, registeredSubscriptions, accountProvider, wallet, requestManagerMiddleware, } = providerOrContext;
|
50
|
+
this.setConfig(config !== null && config !== void 0 ? config : {});
|
51
|
+
this._requestManager =
|
52
|
+
requestManager !== null && requestManager !== void 0 ? requestManager : new Web3RequestManager(provider, (_a = config === null || config === void 0 ? void 0 : config.enableExperimentalFeatures) === null || _a === void 0 ? void 0 : _a.useSubscriptionWhenCheckingBlockTimeout, requestManagerMiddleware);
|
53
|
+
if (subscriptionManager) {
|
54
|
+
this._subscriptionManager = subscriptionManager;
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
this._subscriptionManager = new Web3SubscriptionManager(this.requestManager, registeredSubscriptions !== null && registeredSubscriptions !== void 0 ? registeredSubscriptions : {});
|
58
|
+
}
|
59
|
+
if (accountProvider) {
|
60
|
+
this._accountProvider = accountProvider;
|
61
|
+
}
|
62
|
+
if (wallet) {
|
63
|
+
this._wallet = wallet;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
get requestManager() {
|
67
|
+
return this._requestManager;
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Will return the current subscriptionManager ({@link Web3SubscriptionManager})
|
71
|
+
*/
|
72
|
+
get subscriptionManager() {
|
73
|
+
return this._subscriptionManager;
|
74
|
+
}
|
75
|
+
get wallet() {
|
76
|
+
return this._wallet;
|
77
|
+
}
|
78
|
+
get accountProvider() {
|
79
|
+
return this._accountProvider;
|
80
|
+
}
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
82
|
+
static fromContextObject(...args) {
|
83
|
+
return new this(...args.reverse());
|
84
|
+
}
|
85
|
+
getContextObject() {
|
86
|
+
var _a;
|
87
|
+
return {
|
88
|
+
config: this.config,
|
89
|
+
provider: this.provider,
|
90
|
+
requestManager: this.requestManager,
|
91
|
+
subscriptionManager: this.subscriptionManager,
|
92
|
+
registeredSubscriptions: (_a = this.subscriptionManager) === null || _a === void 0 ? void 0 : _a.registeredSubscriptions,
|
93
|
+
providers: this.providers,
|
94
|
+
wallet: this.wallet,
|
95
|
+
accountProvider: this.accountProvider,
|
96
|
+
};
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Use to create new object of any type extended by `Web3Context`
|
100
|
+
* and link it to current context. This can be used to initiate a global context object
|
101
|
+
* and then use it to create new objects of any type extended by `Web3Context`.
|
102
|
+
*/
|
103
|
+
use(ContextRef, ...args) {
|
104
|
+
const newContextChild = new ContextRef(...[...args, this.getContextObject()]);
|
105
|
+
this.on(Web3ConfigEvent.CONFIG_CHANGE, event => {
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
107
|
+
newContextChild.setConfig({ [event.name]: event.newValue });
|
108
|
+
});
|
109
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
110
|
+
this[ContextRef.name] = newContextChild;
|
111
|
+
return newContextChild;
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Link current context to another context.
|
115
|
+
*/
|
116
|
+
link(parentContext) {
|
117
|
+
this.setConfig(parentContext.config);
|
118
|
+
this._requestManager = parentContext.requestManager;
|
119
|
+
this.provider = parentContext.provider;
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
121
|
+
this._subscriptionManager = parentContext.subscriptionManager;
|
122
|
+
this._wallet = parentContext.wallet;
|
123
|
+
this._accountProvider = parentContext._accountProvider;
|
124
|
+
parentContext.on(Web3ConfigEvent.CONFIG_CHANGE, event => {
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
126
|
+
this.setConfig({ [event.name]: event.newValue });
|
127
|
+
});
|
128
|
+
}
|
129
|
+
// eslint-disable-next-line no-use-before-define
|
130
|
+
registerPlugin(plugin) {
|
131
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
132
|
+
if (this[plugin.pluginNamespace] !== undefined)
|
133
|
+
throw new ExistingPluginNamespaceError(plugin.pluginNamespace);
|
134
|
+
const _pluginObject = {
|
135
|
+
[plugin.pluginNamespace]: plugin,
|
136
|
+
};
|
137
|
+
_pluginObject[plugin.pluginNamespace].link(this);
|
138
|
+
Object.assign(this, _pluginObject);
|
139
|
+
}
|
140
|
+
/**
|
141
|
+
* Will return the current provider.
|
142
|
+
*
|
143
|
+
* @returns Returns the current provider
|
144
|
+
* @example
|
145
|
+
* ```ts
|
146
|
+
* const web3 = new Web3Context("http://localhost:8545");
|
147
|
+
* console.log(web3.provider);
|
148
|
+
* > HttpProvider {
|
149
|
+
* clientUrl: 'http://localhost:8545',
|
150
|
+
* httpProviderOptions: undefined
|
151
|
+
* }
|
152
|
+
* ```
|
153
|
+
*/
|
154
|
+
get provider() {
|
155
|
+
return this.currentProvider;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* Will set the current provider.
|
159
|
+
*
|
160
|
+
* @param provider - The provider to set
|
161
|
+
*
|
162
|
+
* Accepted providers are of type {@link SupportedProviders}
|
163
|
+
* @example
|
164
|
+
* ```ts
|
165
|
+
* const web3Context = new web3ContextContext("http://localhost:8545");
|
166
|
+
* web3Context.provider = "ws://localhost:8545";
|
167
|
+
* console.log(web3Context.provider);
|
168
|
+
* > WebSocketProvider {
|
169
|
+
* _eventEmitter: EventEmitter {
|
170
|
+
* _events: [Object: null prototype] {},
|
171
|
+
* _eventsCount: 0,
|
172
|
+
* ...
|
173
|
+
* }
|
174
|
+
* ```
|
175
|
+
*/
|
176
|
+
set provider(provider) {
|
177
|
+
this.requestManager.setProvider(provider);
|
178
|
+
}
|
179
|
+
/**
|
180
|
+
* Will return the current provider. (The same as `provider`)
|
181
|
+
*
|
182
|
+
* @returns Returns the current provider
|
183
|
+
* @example
|
184
|
+
* ```ts
|
185
|
+
* const web3Context = new Web3Context("http://localhost:8545");
|
186
|
+
* console.log(web3Context.provider);
|
187
|
+
* > HttpProvider {
|
188
|
+
* clientUrl: 'http://localhost:8545',
|
189
|
+
* httpProviderOptions: undefined
|
190
|
+
* }
|
191
|
+
* ```
|
192
|
+
*/
|
193
|
+
get currentProvider() {
|
194
|
+
return this.requestManager.provider;
|
195
|
+
}
|
196
|
+
/**
|
197
|
+
* Will set the current provider. (The same as `provider`)
|
198
|
+
*
|
199
|
+
* @param provider - {@link SupportedProviders} The provider to set
|
200
|
+
*
|
201
|
+
* @example
|
202
|
+
* ```ts
|
203
|
+
* const web3Context = new Web3Context("http://localhost:8545");
|
204
|
+
* web3Context.currentProvider = "ws://localhost:8545";
|
205
|
+
* console.log(web3Context.provider);
|
206
|
+
* > WebSocketProvider {
|
207
|
+
* _eventEmitter: EventEmitter {
|
208
|
+
* _events: [Object: null prototype] {},
|
209
|
+
* _eventsCount: 0,
|
210
|
+
* ...
|
211
|
+
* }
|
212
|
+
* ```
|
213
|
+
*/
|
214
|
+
set currentProvider(provider) {
|
215
|
+
this.requestManager.setProvider(provider);
|
216
|
+
}
|
217
|
+
/**
|
218
|
+
* Will return the givenProvider if available.
|
219
|
+
*
|
220
|
+
* When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise `undefined`.
|
221
|
+
*/
|
222
|
+
// eslint-disable-next-line class-methods-use-this
|
223
|
+
get givenProvider() {
|
224
|
+
return Web3Context.givenProvider;
|
225
|
+
}
|
226
|
+
/**
|
227
|
+
* Will set the provider.
|
228
|
+
*
|
229
|
+
* @param provider - {@link SupportedProviders} The provider to set
|
230
|
+
* @returns Returns true if the provider was set
|
231
|
+
*/
|
232
|
+
setProvider(provider) {
|
233
|
+
this.provider = provider;
|
234
|
+
return true;
|
235
|
+
}
|
236
|
+
setRequestManagerMiddleware(requestManagerMiddleware) {
|
237
|
+
this.requestManager.setMiddleware(requestManagerMiddleware);
|
238
|
+
}
|
239
|
+
/**
|
240
|
+
* Will return the {@link Web3BatchRequest} constructor.
|
241
|
+
*/
|
242
|
+
get BatchRequest() {
|
243
|
+
return Web3BatchRequest.bind(undefined, this._requestManager);
|
244
|
+
}
|
245
|
+
/**
|
246
|
+
* This method allows extending the web3 modules.
|
247
|
+
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
|
248
|
+
*/
|
249
|
+
extend(extendObj) {
|
250
|
+
var _a;
|
251
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
252
|
+
if (extendObj.property && !this[extendObj.property])
|
253
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
254
|
+
this[extendObj.property] = {};
|
255
|
+
(_a = extendObj.methods) === null || _a === void 0 ? void 0 : _a.forEach(element => {
|
256
|
+
const method = (...givenParams) => __awaiter(this, void 0, void 0, function* () {
|
257
|
+
return this.requestManager.send({
|
258
|
+
method: element.call,
|
259
|
+
params: givenParams,
|
260
|
+
});
|
261
|
+
});
|
262
|
+
if (extendObj.property)
|
263
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
265
|
+
this[extendObj.property][element.name] = method;
|
266
|
+
// @ts-expect-error No index signature with a parameter of type 'string' was found on type 'Web3Context<API, RegisteredSubs>'
|
267
|
+
else
|
268
|
+
this[element.name] = method;
|
269
|
+
});
|
270
|
+
return this;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
Web3Context.providers = Web3RequestManager.providers;
|
274
|
+
/**
|
275
|
+
* Extend this class when creating a plugin that either doesn't require {@link EthExecutionAPI},
|
276
|
+
* or interacts with a RPC node that doesn't fully implement {@link EthExecutionAPI}.
|
277
|
+
*
|
278
|
+
* To add type support for RPC methods to the {@link Web3RequestManager},
|
279
|
+
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
|
280
|
+
*
|
281
|
+
* @example
|
282
|
+
* ```ts
|
283
|
+
* type CustomRpcApi = {
|
284
|
+
* custom_rpc_method: () => string;
|
285
|
+
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
|
286
|
+
* };
|
287
|
+
*
|
288
|
+
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
|
289
|
+
* ```
|
290
|
+
*/
|
291
|
+
export class Web3PluginBase extends Web3Context {
|
292
|
+
// eslint-disable-next-line class-methods-use-this
|
293
|
+
registerNewTransactionType(type, txClass) {
|
294
|
+
TransactionFactory.registerTransactionType(type, txClass);
|
295
|
+
}
|
296
|
+
}
|
297
|
+
/**
|
298
|
+
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
|
299
|
+
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
|
300
|
+
*
|
301
|
+
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
|
302
|
+
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
|
303
|
+
*
|
304
|
+
* @example
|
305
|
+
* ```ts
|
306
|
+
* type CustomRpcApi = {
|
307
|
+
* custom_rpc_method: () => string;
|
308
|
+
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
|
309
|
+
* };
|
310
|
+
*
|
311
|
+
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
|
312
|
+
* ```
|
313
|
+
*/
|
314
|
+
export class Web3EthPluginBase extends Web3PluginBase {
|
315
|
+
}
|
316
|
+
//# sourceMappingURL=web3_context.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"web3_context.js","sourceRoot":"","sources":["../../src/web3_context.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;EAeE;AACF,gDAAgD;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAa3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAmB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,2CAA2C;AAC3C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAmDzE,MAAM,OAAO,WAMX,SAAQ,UAAU;IASnB,YACC,iBAG8C;;Q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oBACpB,MAAM,EAAE,WAAW;iBACnB,CAAC,CAAA;cAAA,CAAC;YAEJ,IAAI,SAAS,CAAC,QAAQ;gBACrB,6HAA6H;gBAC7H,sEAAsE;gBACtE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YACjD,6HAA6H;;gBACxH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;;AArTsB,qBAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC;AAwTjE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,cAEpB,SAAQ,WAAgB;IAGzB,kDAAkD;IACxC,0BAA0B,CACnC,IAAa,EACb,OAAuB;QAEvB,kBAAkB,CAAC,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;CACD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,iBAAqD,SAAQ,cAElF;CAAG"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/*
|
2
|
+
This file is part of web3.js.
|
3
|
+
|
4
|
+
web3.js is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU Lesser General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
web3.js is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public License
|
15
|
+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
*/
|
17
|
+
import { EventEmitter } from 'web3-utils';
|
18
|
+
export class Web3EventEmitter {
|
19
|
+
constructor() {
|
20
|
+
this._emitter = new EventEmitter();
|
21
|
+
}
|
22
|
+
on(eventName, fn) {
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
24
|
+
this._emitter.on(eventName, fn);
|
25
|
+
}
|
26
|
+
once(eventName, fn) {
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
28
|
+
this._emitter.once(eventName, fn);
|
29
|
+
}
|
30
|
+
off(eventName, fn) {
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
32
|
+
this._emitter.off(eventName, fn);
|
33
|
+
}
|
34
|
+
emit(eventName, params) {
|
35
|
+
this._emitter.emit(eventName, params);
|
36
|
+
}
|
37
|
+
listenerCount(eventName) {
|
38
|
+
return this._emitter.listenerCount(eventName);
|
39
|
+
}
|
40
|
+
listeners(eventName) {
|
41
|
+
return this._emitter.listeners(eventName);
|
42
|
+
}
|
43
|
+
eventNames() {
|
44
|
+
return this._emitter.eventNames();
|
45
|
+
}
|
46
|
+
removeAllListeners() {
|
47
|
+
return this._emitter.removeAllListeners();
|
48
|
+
}
|
49
|
+
setMaxListenerWarningThreshold(maxListenersWarningThreshold) {
|
50
|
+
this._emitter.setMaxListeners(maxListenersWarningThreshold);
|
51
|
+
}
|
52
|
+
getMaxListeners() {
|
53
|
+
return this._emitter.getMaxListeners();
|
54
|
+
}
|
55
|
+
}
|
56
|
+
//# sourceMappingURL=web3_event_emitter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"web3_event_emitter.js","sourceRoot":"","sources":["../../src/web3_event_emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAY1C,MAAM,OAAO,gBAAgB;IAA7B;QACkB,aAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IA0ChD,CAAC;IAxCO,EAAE,CAA4B,SAAY,EAAE,EAA2B;QAC7E,kEAAkE;QAClE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,IAAI,CAA4B,SAAY,EAAE,EAA2B;QAC/E,kEAAkE;QAClE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;IAEM,GAAG,CAA4B,SAAY,EAAE,EAA2B;QAC9E,kEAAkE;QAClE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IAEM,IAAI,CAA4B,SAAY,EAAE,MAAY;QAChE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAEM,aAAa,CAA4B,SAAY;QAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAEM,SAAS,CAA4B,SAAY;QACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAEM,UAAU;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;IAEM,kBAAkB;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IAC3C,CAAC;IACM,8BAA8B,CAAC,4BAAoC;QACzE,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;IAC7D,CAAC;IACM,eAAe;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC;CACD"}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/*
|
2
|
+
This file is part of web3.js.
|
3
|
+
|
4
|
+
web3.js is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU Lesser General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
web3.js is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public License
|
15
|
+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
*/
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var _a;
|
27
|
+
import { Web3EventEmitter, } from './web3_event_emitter.js';
|
28
|
+
export class Web3PromiEvent extends Web3EventEmitter {
|
29
|
+
constructor(executor) {
|
30
|
+
super();
|
31
|
+
// public tag to treat object as promise by different libs
|
32
|
+
// eslint-disable-next-line @typescript-eslint/prefer-as-const
|
33
|
+
this[_a] = 'Promise';
|
34
|
+
this._promise = new Promise(executor);
|
35
|
+
}
|
36
|
+
then(onfulfilled, onrejected) {
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
38
|
+
return this._promise.then(onfulfilled, onrejected);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
catch(onrejected) {
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
43
|
+
return this._promise.catch(onrejected);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
finally(onfinally) {
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
48
|
+
return this._promise.finally(onfinally);
|
49
|
+
});
|
50
|
+
}
|
51
|
+
on(eventName, fn) {
|
52
|
+
super.on(eventName, fn);
|
53
|
+
return this;
|
54
|
+
}
|
55
|
+
once(eventName, fn) {
|
56
|
+
super.once(eventName, fn);
|
57
|
+
return this;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
_a = Symbol.toStringTag;
|
61
|
+
//# sourceMappingURL=web3_promi_event.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"web3_promi_event.js","sourceRoot":"","sources":["../../src/web3_promi_event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;;;;;;;;;;;AAEF,OAAO,EAEN,gBAAgB,GAGhB,MAAM,yBAAyB,CAAC;AAOjC,MAAM,OAAO,cACZ,SAAQ,gBAA0B;IAKlC,YAAmB,QAAsC;QACxD,KAAK,EAAE,CAAC;QAIT,0DAA0D;QAC1D,8DAA8D;QACvD,QAAoB,GAAc,SAAS,CAAC;QALlD,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAc,QAAQ,CAAC,CAAC;IACpD,CAAC;IAMY,IAAI,CAChB,WAAoF,EACpF,UAAgF;;YAEhF,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACpD,CAAC;KAAA;IAEY,KAAK,CACjB,UAA8E;;YAE9E,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;KAAA;IAEY,OAAO,CAAC,SAAoC;;YACxD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;KAAA;IAEM,EAAE,CACR,SAAY,EACZ,EAAkC;QAElC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,IAAI,CACV,SAAY,EACZ,EAAkC;QAElC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAE1B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;KApCQ,MAAM,CAAC,WAAW"}
|