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,436 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
This file is part of web3.js.
|
4
|
+
|
5
|
+
web3.js is free software: you can redistribute it and/or modify
|
6
|
+
it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
web3.js is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU Lesser General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Lesser General Public License
|
16
|
+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
19
|
+
exports.Web3Config = exports.Web3ConfigEvent = void 0;
|
20
|
+
const web3_types_1 = require("web3-types");
|
21
|
+
const web3_errors_1 = require("web3-errors");
|
22
|
+
const web3_utils_1 = require("web3-utils");
|
23
|
+
const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
|
24
|
+
var Web3ConfigEvent;
|
25
|
+
(function (Web3ConfigEvent) {
|
26
|
+
Web3ConfigEvent["CONFIG_CHANGE"] = "CONFIG_CHANGE";
|
27
|
+
})(Web3ConfigEvent = exports.Web3ConfigEvent || (exports.Web3ConfigEvent = {}));
|
28
|
+
class Web3Config extends web3_event_emitter_js_1.Web3EventEmitter {
|
29
|
+
constructor(options) {
|
30
|
+
super();
|
31
|
+
this.config = {
|
32
|
+
handleRevert: false,
|
33
|
+
defaultAccount: undefined,
|
34
|
+
defaultBlock: 'latest',
|
35
|
+
transactionBlockTimeout: 50,
|
36
|
+
transactionConfirmationBlocks: 24,
|
37
|
+
transactionPollingInterval: 1000,
|
38
|
+
transactionPollingTimeout: 750 * 1000,
|
39
|
+
transactionReceiptPollingInterval: undefined,
|
40
|
+
transactionSendTimeout: 750 * 1000,
|
41
|
+
transactionConfirmationPollingInterval: undefined,
|
42
|
+
blockHeaderTimeout: 10,
|
43
|
+
maxListenersWarningThreshold: 100,
|
44
|
+
contractDataInputFill: 'data',
|
45
|
+
defaultNetworkId: undefined,
|
46
|
+
defaultChain: 'mainnet',
|
47
|
+
defaultHardfork: 'london',
|
48
|
+
// TODO - Check if there is a default Common
|
49
|
+
defaultCommon: undefined,
|
50
|
+
defaultTransactionType: '0x2',
|
51
|
+
defaultMaxPriorityFeePerGas: (0, web3_utils_1.toHex)(2500000000),
|
52
|
+
enableExperimentalFeatures: {
|
53
|
+
useSubscriptionWhenCheckingBlockTimeout: false,
|
54
|
+
useRpcCallSpecification: false,
|
55
|
+
},
|
56
|
+
transactionBuilder: undefined,
|
57
|
+
transactionTypeParser: undefined,
|
58
|
+
customTransactionSchema: undefined,
|
59
|
+
defaultReturnFormat: web3_types_1.DEFAULT_RETURN_FORMAT,
|
60
|
+
ignoreGasPricing: false,
|
61
|
+
};
|
62
|
+
this.setConfig(options !== null && options !== void 0 ? options : {});
|
63
|
+
}
|
64
|
+
setConfig(options) {
|
65
|
+
// TODO: Improve and add key check
|
66
|
+
const keys = Object.keys(options);
|
67
|
+
for (const key of keys) {
|
68
|
+
this._triggerConfigChange(key, options[key]);
|
69
|
+
if (!(0, web3_utils_1.isNullish)(options[key]) &&
|
70
|
+
typeof options[key] === 'number' &&
|
71
|
+
key === 'maxListenersWarningThreshold') {
|
72
|
+
// additionally set in event emitter
|
73
|
+
this.setMaxListenerWarningThreshold(Number(options[key]));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
Object.assign(this.config, options);
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* The `handleRevert` options property returns the revert reason string if enabled for the following methods:
|
80
|
+
* - web3.eth.sendTransaction()
|
81
|
+
* - web3.eth.call()
|
82
|
+
* - myContract.methods.myMethod().call()
|
83
|
+
* - myContract.methods.myMethod().send()
|
84
|
+
* Default is `false`.
|
85
|
+
*
|
86
|
+
* `Note`: At the moment `handleRevert` is only supported for `sendTransaction` and not for `sendSignedTransaction`
|
87
|
+
*/
|
88
|
+
get handleRevert() {
|
89
|
+
return this.config.handleRevert;
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Will set the handleRevert
|
93
|
+
*/
|
94
|
+
set handleRevert(val) {
|
95
|
+
this._triggerConfigChange('handleRevert', val);
|
96
|
+
this.config.handleRevert = val;
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* The `contractDataInputFill` options property will allow you to set the hash of the method signature and encoded parameters to the property
|
100
|
+
* either `data`, `input` or both within your contract.
|
101
|
+
* This will affect the contracts send, call and estimateGas methods
|
102
|
+
* Default is `data`.
|
103
|
+
*/
|
104
|
+
get contractDataInputFill() {
|
105
|
+
return this.config.contractDataInputFill;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* Will set the contractDataInputFill
|
109
|
+
*/
|
110
|
+
set contractDataInputFill(val) {
|
111
|
+
this._triggerConfigChange('contractDataInputFill', val);
|
112
|
+
this.config.contractDataInputFill = val;
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* This default address is used as the default `from` property, if no `from` property is specified in for the following methods:
|
116
|
+
* - web3.eth.sendTransaction()
|
117
|
+
* - web3.eth.call()
|
118
|
+
* - myContract.methods.myMethod().call()
|
119
|
+
* - myContract.methods.myMethod().send()
|
120
|
+
*/
|
121
|
+
get defaultAccount() {
|
122
|
+
return this.config.defaultAccount;
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* Will set the default account.
|
126
|
+
*/
|
127
|
+
set defaultAccount(val) {
|
128
|
+
this._triggerConfigChange('defaultAccount', val);
|
129
|
+
this.config.defaultAccount = val;
|
130
|
+
}
|
131
|
+
/**
|
132
|
+
* The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. The default value is `"latest"`.
|
133
|
+
* - web3.eth.getBalance()
|
134
|
+
* - web3.eth.getCode()
|
135
|
+
* - web3.eth.getTransactionCount()
|
136
|
+
* - web3.eth.getStorageAt()
|
137
|
+
* - web3.eth.call()
|
138
|
+
* - myContract.methods.myMethod().call()
|
139
|
+
*/
|
140
|
+
get defaultBlock() {
|
141
|
+
return this.config.defaultBlock;
|
142
|
+
}
|
143
|
+
/**
|
144
|
+
* Will set the default block.
|
145
|
+
*
|
146
|
+
* - A block number
|
147
|
+
* - `"earliest"` - String: The genesis block
|
148
|
+
* - `"latest"` - String: The latest block (current head of the blockchain)
|
149
|
+
* - `"pending"` - String: The currently mined block (including pending transactions)
|
150
|
+
* - `"finalized"` - String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators
|
151
|
+
* - `"safe"` - String: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work network's latest blocks.
|
152
|
+
*/
|
153
|
+
set defaultBlock(val) {
|
154
|
+
this._triggerConfigChange('defaultBlock', val);
|
155
|
+
this.config.defaultBlock = val;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* The time used to wait for Ethereum Node to return the sent transaction result.
|
159
|
+
* Note: If the RPC call stuck at the Node and therefor timed-out, the transaction may still be pending or even mined by the Network. We recommend checking the pending transactions in such a case.
|
160
|
+
* Default is `750` seconds (12.5 minutes).
|
161
|
+
*/
|
162
|
+
get transactionSendTimeout() {
|
163
|
+
return this.config.transactionSendTimeout;
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* Will set the transactionSendTimeout.
|
167
|
+
*/
|
168
|
+
set transactionSendTimeout(val) {
|
169
|
+
this._triggerConfigChange('transactionSendTimeout', val);
|
170
|
+
this.config.transactionSendTimeout = val;
|
171
|
+
}
|
172
|
+
/**
|
173
|
+
* The `transactionBlockTimeout` is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error.
|
174
|
+
* Default is `50`.
|
175
|
+
*/
|
176
|
+
get transactionBlockTimeout() {
|
177
|
+
return this.config.transactionBlockTimeout;
|
178
|
+
}
|
179
|
+
/**
|
180
|
+
* Will set the transactionBlockTimeout.
|
181
|
+
*/
|
182
|
+
set transactionBlockTimeout(val) {
|
183
|
+
this._triggerConfigChange('transactionBlockTimeout', val);
|
184
|
+
this.config.transactionBlockTimeout = val;
|
185
|
+
}
|
186
|
+
/**
|
187
|
+
* This defines the number of blocks it requires until a transaction is considered confirmed.
|
188
|
+
* Default is `24`.
|
189
|
+
*/
|
190
|
+
get transactionConfirmationBlocks() {
|
191
|
+
return this.config.transactionConfirmationBlocks;
|
192
|
+
}
|
193
|
+
/**
|
194
|
+
* Will set the transactionConfirmationBlocks.
|
195
|
+
*/
|
196
|
+
set transactionConfirmationBlocks(val) {
|
197
|
+
this._triggerConfigChange('transactionConfirmationBlocks', val);
|
198
|
+
this.config.transactionConfirmationBlocks = val;
|
199
|
+
}
|
200
|
+
/**
|
201
|
+
* Used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network.
|
202
|
+
* Default is `1000` ms.
|
203
|
+
*/
|
204
|
+
get transactionPollingInterval() {
|
205
|
+
return this.config.transactionPollingInterval;
|
206
|
+
}
|
207
|
+
/**
|
208
|
+
* Will set the transactionPollingInterval.
|
209
|
+
*/
|
210
|
+
set transactionPollingInterval(val) {
|
211
|
+
this._triggerConfigChange('transactionPollingInterval', val);
|
212
|
+
this.config.transactionPollingInterval = val;
|
213
|
+
this.transactionReceiptPollingInterval = val;
|
214
|
+
this.transactionConfirmationPollingInterval = val;
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* Used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending.
|
218
|
+
* Default is `750` seconds (12.5 minutes).
|
219
|
+
*/
|
220
|
+
get transactionPollingTimeout() {
|
221
|
+
return this.config.transactionPollingTimeout;
|
222
|
+
}
|
223
|
+
/**
|
224
|
+
* Will set the transactionPollingTimeout.
|
225
|
+
*/
|
226
|
+
set transactionPollingTimeout(val) {
|
227
|
+
this._triggerConfigChange('transactionPollingTimeout', val);
|
228
|
+
this.config.transactionPollingTimeout = val;
|
229
|
+
}
|
230
|
+
/**
|
231
|
+
* The `transactionPollingInterval` is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network.
|
232
|
+
* Default is `undefined`
|
233
|
+
*/
|
234
|
+
get transactionReceiptPollingInterval() {
|
235
|
+
return this.config.transactionReceiptPollingInterval;
|
236
|
+
}
|
237
|
+
/**
|
238
|
+
* Will set the transactionReceiptPollingInterval
|
239
|
+
*/
|
240
|
+
set transactionReceiptPollingInterval(val) {
|
241
|
+
this._triggerConfigChange('transactionReceiptPollingInterval', val);
|
242
|
+
this.config.transactionReceiptPollingInterval = val;
|
243
|
+
}
|
244
|
+
get transactionConfirmationPollingInterval() {
|
245
|
+
return this.config.transactionConfirmationPollingInterval;
|
246
|
+
}
|
247
|
+
set transactionConfirmationPollingInterval(val) {
|
248
|
+
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
|
249
|
+
this.config.transactionConfirmationPollingInterval = val;
|
250
|
+
}
|
251
|
+
/**
|
252
|
+
* The blockHeaderTimeout is used over socket-based connections. This option defines the amount seconds it should wait for `'newBlockHeaders'` event before falling back to polling to fetch transaction receipt.
|
253
|
+
* Default is `10` seconds.
|
254
|
+
*/
|
255
|
+
get blockHeaderTimeout() {
|
256
|
+
return this.config.blockHeaderTimeout;
|
257
|
+
}
|
258
|
+
/**
|
259
|
+
* Will set the blockHeaderTimeout
|
260
|
+
*/
|
261
|
+
set blockHeaderTimeout(val) {
|
262
|
+
this._triggerConfigChange('blockHeaderTimeout', val);
|
263
|
+
this.config.blockHeaderTimeout = val;
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* The enableExperimentalFeatures is used to enable trying new experimental features that are still not fully implemented or not fully tested or still have some related issues.
|
267
|
+
* Default is `false` for every feature.
|
268
|
+
*/
|
269
|
+
get enableExperimentalFeatures() {
|
270
|
+
return this.config.enableExperimentalFeatures;
|
271
|
+
}
|
272
|
+
/**
|
273
|
+
* Will set the enableExperimentalFeatures
|
274
|
+
*/
|
275
|
+
set enableExperimentalFeatures(val) {
|
276
|
+
this._triggerConfigChange('enableExperimentalFeatures', val);
|
277
|
+
this.config.enableExperimentalFeatures = val;
|
278
|
+
}
|
279
|
+
get maxListenersWarningThreshold() {
|
280
|
+
return this.config.maxListenersWarningThreshold;
|
281
|
+
}
|
282
|
+
set maxListenersWarningThreshold(val) {
|
283
|
+
this._triggerConfigChange('maxListenersWarningThreshold', val);
|
284
|
+
this.setMaxListenerWarningThreshold(val);
|
285
|
+
this.config.maxListenersWarningThreshold = val;
|
286
|
+
}
|
287
|
+
get defaultReturnFormat() {
|
288
|
+
return this.config.defaultReturnFormat;
|
289
|
+
}
|
290
|
+
set defaultReturnFormat(val) {
|
291
|
+
this._triggerConfigChange('defaultReturnFormat', val);
|
292
|
+
this.config.defaultReturnFormat = val;
|
293
|
+
}
|
294
|
+
get defaultNetworkId() {
|
295
|
+
return this.config.defaultNetworkId;
|
296
|
+
}
|
297
|
+
set defaultNetworkId(val) {
|
298
|
+
this._triggerConfigChange('defaultNetworkId', val);
|
299
|
+
this.config.defaultNetworkId = val;
|
300
|
+
}
|
301
|
+
get defaultChain() {
|
302
|
+
return this.config.defaultChain;
|
303
|
+
}
|
304
|
+
set defaultChain(val) {
|
305
|
+
if (!(0, web3_utils_1.isNullish)(this.config.defaultCommon) &&
|
306
|
+
!(0, web3_utils_1.isNullish)(this.config.defaultCommon.baseChain) &&
|
307
|
+
val !== this.config.defaultCommon.baseChain)
|
308
|
+
throw new web3_errors_1.ConfigChainMismatchError(this.config.defaultChain, val);
|
309
|
+
this._triggerConfigChange('defaultChain', val);
|
310
|
+
this.config.defaultChain = val;
|
311
|
+
}
|
312
|
+
/**
|
313
|
+
* Will return the default hardfork. Default is `london`
|
314
|
+
* The default hardfork property can be one of the following:
|
315
|
+
* - `chainstart`
|
316
|
+
* - `homestead`
|
317
|
+
* - `dao`
|
318
|
+
* - `tangerineWhistle`
|
319
|
+
* - `spuriousDragon`
|
320
|
+
* - `byzantium`
|
321
|
+
* - `constantinople`
|
322
|
+
* - `petersburg`
|
323
|
+
* - `istanbul`
|
324
|
+
* - `berlin`
|
325
|
+
* - `london`
|
326
|
+
* - 'arrowGlacier',
|
327
|
+
* - 'tangerineWhistle',
|
328
|
+
* - 'muirGlacier'
|
329
|
+
*
|
330
|
+
*/
|
331
|
+
get defaultHardfork() {
|
332
|
+
return this.config.defaultHardfork;
|
333
|
+
}
|
334
|
+
/**
|
335
|
+
* Will set the default hardfork.
|
336
|
+
*
|
337
|
+
*/
|
338
|
+
set defaultHardfork(val) {
|
339
|
+
if (!(0, web3_utils_1.isNullish)(this.config.defaultCommon) &&
|
340
|
+
!(0, web3_utils_1.isNullish)(this.config.defaultCommon.hardfork) &&
|
341
|
+
val !== this.config.defaultCommon.hardfork)
|
342
|
+
throw new web3_errors_1.ConfigHardforkMismatchError(this.config.defaultCommon.hardfork, val);
|
343
|
+
this._triggerConfigChange('defaultHardfork', val);
|
344
|
+
this.config.defaultHardfork = val;
|
345
|
+
}
|
346
|
+
/**
|
347
|
+
*
|
348
|
+
* Will get the default common property
|
349
|
+
* The default common property does contain the following Common object:
|
350
|
+
* - `customChain` - `Object`: The custom chain properties
|
351
|
+
* - `name` - `string`: (optional) The name of the chain
|
352
|
+
* - `networkId` - `number`: Network ID of the custom chain
|
353
|
+
* - `chainId` - `number`: Chain ID of the custom chain
|
354
|
+
* - `baseChain` - `string`: (optional) mainnet, goerli, kovan, rinkeby, or ropsten
|
355
|
+
* - `hardfork` - `string`: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london
|
356
|
+
* Default is `undefined`.
|
357
|
+
*
|
358
|
+
*/
|
359
|
+
get defaultCommon() {
|
360
|
+
return this.config.defaultCommon;
|
361
|
+
}
|
362
|
+
/**
|
363
|
+
* Will set the default common property
|
364
|
+
*
|
365
|
+
*/
|
366
|
+
set defaultCommon(val) {
|
367
|
+
// validation check if default hardfork is set and matches defaultCommon hardfork
|
368
|
+
if (!(0, web3_utils_1.isNullish)(this.config.defaultHardfork) &&
|
369
|
+
!(0, web3_utils_1.isNullish)(val) &&
|
370
|
+
!(0, web3_utils_1.isNullish)(val.hardfork) &&
|
371
|
+
this.config.defaultHardfork !== val.hardfork)
|
372
|
+
throw new web3_errors_1.ConfigHardforkMismatchError(this.config.defaultHardfork, val.hardfork);
|
373
|
+
if (!(0, web3_utils_1.isNullish)(this.config.defaultChain) &&
|
374
|
+
!(0, web3_utils_1.isNullish)(val) &&
|
375
|
+
!(0, web3_utils_1.isNullish)(val.baseChain) &&
|
376
|
+
this.config.defaultChain !== val.baseChain)
|
377
|
+
throw new web3_errors_1.ConfigChainMismatchError(this.config.defaultChain, val.baseChain);
|
378
|
+
this._triggerConfigChange('defaultCommon', val);
|
379
|
+
this.config.defaultCommon = val;
|
380
|
+
}
|
381
|
+
/**
|
382
|
+
* Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object.
|
383
|
+
* Useful when you want wallets to handle gas pricing.
|
384
|
+
*/
|
385
|
+
get ignoreGasPricing() {
|
386
|
+
return this.config.ignoreGasPricing;
|
387
|
+
}
|
388
|
+
set ignoreGasPricing(val) {
|
389
|
+
this._triggerConfigChange('ignoreGasPricing', val);
|
390
|
+
this.config.ignoreGasPricing = val;
|
391
|
+
}
|
392
|
+
get defaultTransactionType() {
|
393
|
+
return this.config.defaultTransactionType;
|
394
|
+
}
|
395
|
+
set defaultTransactionType(val) {
|
396
|
+
this._triggerConfigChange('defaultTransactionType', val);
|
397
|
+
this.config.defaultTransactionType = val;
|
398
|
+
}
|
399
|
+
get defaultMaxPriorityFeePerGas() {
|
400
|
+
return this.config.defaultMaxPriorityFeePerGas;
|
401
|
+
}
|
402
|
+
set defaultMaxPriorityFeePerGas(val) {
|
403
|
+
this._triggerConfigChange('defaultMaxPriorityFeePerGas', val);
|
404
|
+
this.config.defaultMaxPriorityFeePerGas = val;
|
405
|
+
}
|
406
|
+
get transactionBuilder() {
|
407
|
+
return this.config.transactionBuilder;
|
408
|
+
}
|
409
|
+
set transactionBuilder(val) {
|
410
|
+
this._triggerConfigChange('transactionBuilder', val);
|
411
|
+
this.config.transactionBuilder = val;
|
412
|
+
}
|
413
|
+
get transactionTypeParser() {
|
414
|
+
return this.config.transactionTypeParser;
|
415
|
+
}
|
416
|
+
set transactionTypeParser(val) {
|
417
|
+
this._triggerConfigChange('transactionTypeParser', val);
|
418
|
+
this.config.transactionTypeParser = val;
|
419
|
+
}
|
420
|
+
get customTransactionSchema() {
|
421
|
+
return this.config.customTransactionSchema;
|
422
|
+
}
|
423
|
+
set customTransactionSchema(schema) {
|
424
|
+
this._triggerConfigChange('customTransactionSchema', schema);
|
425
|
+
this.config.customTransactionSchema = schema;
|
426
|
+
}
|
427
|
+
_triggerConfigChange(config, newValue) {
|
428
|
+
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
|
429
|
+
name: config,
|
430
|
+
oldValue: this.config[config],
|
431
|
+
newValue,
|
432
|
+
});
|
433
|
+
}
|
434
|
+
}
|
435
|
+
exports.Web3Config = Web3Config;
|
436
|
+
//# sourceMappingURL=web3_config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"web3_config.js","sourceRoot":"","sources":["../../src/web3_config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;EAeE;;;AAEF,2CAOoB;AACpB,6CAAoF;AACpF,2CAA8C;AAI9C,mEAA2D;AAwC3D,IAAY,eAEX;AAFD,WAAY,eAAe;IAC1B,kDAA+B,CAAA;AAChC,CAAC,EAFW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAE1B;AAED,MAAsB,UACrB,SAAQ,wCAAqF;IAmC7F,YAAmB,OAAoC;QACtD,KAAK,EAAE,CAAC;QAjCF,WAAM,GAAsB;YAClC,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,SAAS;YACzB,YAAY,EAAE,QAAQ;YACtB,uBAAuB,EAAE,EAAE;YAC3B,6BAA6B,EAAE,EAAE;YACjC,0BAA0B,EAAE,IAAI;YAChC,yBAAyB,EAAE,GAAG,GAAG,IAAI;YACrC,iCAAiC,EAAE,SAAS;YAC5C,sBAAsB,EAAE,GAAG,GAAG,IAAI;YAClC,sCAAsC,EAAE,SAAS;YACjD,kBAAkB,EAAE,EAAE;YACtB,4BAA4B,EAAE,GAAG;YACjC,qBAAqB,EAAE,MAAM;YAC7B,gBAAgB,EAAE,SAAS;YAC3B,YAAY,EAAE,SAAS;YACvB,eAAe,EAAE,QAAQ;YACzB,4CAA4C;YAC5C,aAAa,EAAE,SAAS;YACxB,sBAAsB,EAAE,KAAK;YAC7B,2BAA2B,EAAE,IAAA,kBAAK,EAAC,UAAU,CAAC;YAC9C,0BAA0B,EAAE;gBAC3B,uCAAuC,EAAE,KAAK;gBAC9C,uBAAuB,EAAE,KAAK;aAC9B;YACD,kBAAkB,EAAE,SAAS;YAC7B,qBAAqB,EAAE,SAAS;YAChC,uB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,IAAW,uBAAuB,CAAC,MAA2C;QAC7E,IAAI,CAAC,oBAAoB,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,uBAAuB,GAAG,MAAM,CAAC;IAC9C,CAAC;IAEO,oBAAoB,CAC3B,MAAS,EACT,QAA8B;QAE9B,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE;YACxC,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAC7B,QAAQ;SAC0B,CAAC,CAAC;IACtC,CAAC;CACD;AAleD,gCAkeC"}
|
@@ -0,0 +1,212 @@
|
|
1
|
+
import { EthExecutionAPI, HexString, Numbers, SupportedProviders, Transaction, Web3AccountProvider, Web3APISpec, Web3BaseProvider, Web3BaseWallet, Web3BaseWalletAccount } from 'web3-types';
|
2
|
+
import { BaseTransaction } from 'web3-eth-accounts';
|
3
|
+
import { ExtensionObject, RequestManagerMiddleware } from './types.js';
|
4
|
+
import { Web3BatchRequest } from './web3_batch_request.js';
|
5
|
+
import { Web3Config, Web3ConfigOptions } from './web3_config.js';
|
6
|
+
import { Web3RequestManager } from './web3_request_manager.js';
|
7
|
+
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
|
8
|
+
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
|
9
|
+
export declare type Web3ContextObject<API extends Web3APISpec = unknown, RegisteredSubs extends {
|
10
|
+
[key: string]: Web3SubscriptionConstructor<API>;
|
11
|
+
} = any> = {
|
12
|
+
config: Web3ConfigOptions;
|
13
|
+
provider?: SupportedProviders<API> | string;
|
14
|
+
requestManager: Web3RequestManager<API>;
|
15
|
+
subscriptionManager?: Web3SubscriptionManager<API, RegisteredSubs> | undefined;
|
16
|
+
registeredSubscriptions?: RegisteredSubs;
|
17
|
+
providers: typeof Web3RequestManager.providers;
|
18
|
+
accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
|
19
|
+
wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
|
20
|
+
};
|
21
|
+
export declare type Web3ContextInitOptions<API extends Web3APISpec = unknown, RegisteredSubs extends {
|
22
|
+
[key: string]: Web3SubscriptionConstructor<API>;
|
23
|
+
} = any> = {
|
24
|
+
config?: Partial<Web3ConfigOptions>;
|
25
|
+
provider?: SupportedProviders<API> | string;
|
26
|
+
requestManager?: Web3RequestManager<API>;
|
27
|
+
subscriptionManager?: Web3SubscriptionManager<API, RegisteredSubs> | undefined;
|
28
|
+
registeredSubscriptions?: RegisteredSubs;
|
29
|
+
accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
|
30
|
+
wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
|
31
|
+
requestManagerMiddleware?: RequestManagerMiddleware<API>;
|
32
|
+
};
|
33
|
+
export declare type Web3ContextConstructor<T extends Web3Context, T2 extends unknown[]> = new (...args: [...extras: T2, context: Web3ContextObject]) => T;
|
34
|
+
export declare type Web3ContextFactory<T extends Web3Context, T2 extends unknown[]> = Web3ContextConstructor<T, T2> & {
|
35
|
+
fromContextObject(this: Web3ContextConstructor<T, T2>, contextObject: Web3ContextObject): T;
|
36
|
+
};
|
37
|
+
export declare class Web3Context<API extends Web3APISpec = unknown, RegisteredSubs extends {
|
38
|
+
[key: string]: Web3SubscriptionConstructor<API>;
|
39
|
+
} = any> extends Web3Config {
|
40
|
+
static readonly providers: {
|
41
|
+
HttpProvider: import("web3-types").Web3BaseProviderConstructor;
|
42
|
+
WebsocketProvider: import("web3-types").Web3BaseProviderConstructor;
|
43
|
+
};
|
44
|
+
static givenProvider?: SupportedProviders<never>;
|
45
|
+
readonly providers: {
|
46
|
+
HttpProvider: import("web3-types").Web3BaseProviderConstructor;
|
47
|
+
WebsocketProvider: import("web3-types").Web3BaseProviderConstructor;
|
48
|
+
};
|
49
|
+
protected _requestManager: Web3RequestManager<API>;
|
50
|
+
protected _subscriptionManager: Web3SubscriptionManager<API, RegisteredSubs>;
|
51
|
+
protected _accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
|
52
|
+
protected _wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
|
53
|
+
constructor(providerOrContext?: string | SupportedProviders<API> | Web3ContextInitOptions<API, RegisteredSubs>);
|
54
|
+
get requestManager(): Web3RequestManager<API>;
|
55
|
+
/**
|
56
|
+
* Will return the current subscriptionManager ({@link Web3SubscriptionManager})
|
57
|
+
*/
|
58
|
+
get subscriptionManager(): Web3SubscriptionManager<API, RegisteredSubs>;
|
59
|
+
get wallet(): Web3BaseWallet<Web3BaseWalletAccount> | undefined;
|
60
|
+
get accountProvider(): Web3AccountProvider<Web3BaseWalletAccount> | undefined;
|
61
|
+
static fromContextObject<T extends Web3Context, T3 extends unknown[]>(this: Web3ContextConstructor<T, T3>, ...args: [Web3ContextObject, ...T3]): T;
|
62
|
+
getContextObject(): Web3ContextObject<API, RegisteredSubs>;
|
63
|
+
/**
|
64
|
+
* Use to create new object of any type extended by `Web3Context`
|
65
|
+
* and link it to current context. This can be used to initiate a global context object
|
66
|
+
* and then use it to create new objects of any type extended by `Web3Context`.
|
67
|
+
*/
|
68
|
+
use<T extends Web3Context, T2 extends unknown[]>(ContextRef: Web3ContextConstructor<T, T2>, ...args: [...T2]): T;
|
69
|
+
/**
|
70
|
+
* Link current context to another context.
|
71
|
+
*/
|
72
|
+
link<T extends Web3Context>(parentContext: T): void;
|
73
|
+
registerPlugin(plugin: Web3PluginBase): void;
|
74
|
+
/**
|
75
|
+
* Will return the current provider.
|
76
|
+
*
|
77
|
+
* @returns Returns the current provider
|
78
|
+
* @example
|
79
|
+
* ```ts
|
80
|
+
* const web3 = new Web3Context("http://localhost:8545");
|
81
|
+
* console.log(web3.provider);
|
82
|
+
* > HttpProvider {
|
83
|
+
* clientUrl: 'http://localhost:8545',
|
84
|
+
* httpProviderOptions: undefined
|
85
|
+
* }
|
86
|
+
* ```
|
87
|
+
*/
|
88
|
+
get provider(): Web3BaseProvider<API> | undefined;
|
89
|
+
/**
|
90
|
+
* Will set the current provider.
|
91
|
+
*
|
92
|
+
* @param provider - The provider to set
|
93
|
+
*
|
94
|
+
* Accepted providers are of type {@link SupportedProviders}
|
95
|
+
* @example
|
96
|
+
* ```ts
|
97
|
+
* const web3Context = new web3ContextContext("http://localhost:8545");
|
98
|
+
* web3Context.provider = "ws://localhost:8545";
|
99
|
+
* console.log(web3Context.provider);
|
100
|
+
* > WebSocketProvider {
|
101
|
+
* _eventEmitter: EventEmitter {
|
102
|
+
* _events: [Object: null prototype] {},
|
103
|
+
* _eventsCount: 0,
|
104
|
+
* ...
|
105
|
+
* }
|
106
|
+
* ```
|
107
|
+
*/
|
108
|
+
set provider(provider: SupportedProviders<API> | string | undefined);
|
109
|
+
/**
|
110
|
+
* Will return the current provider. (The same as `provider`)
|
111
|
+
*
|
112
|
+
* @returns Returns the current provider
|
113
|
+
* @example
|
114
|
+
* ```ts
|
115
|
+
* const web3Context = new Web3Context("http://localhost:8545");
|
116
|
+
* console.log(web3Context.provider);
|
117
|
+
* > HttpProvider {
|
118
|
+
* clientUrl: 'http://localhost:8545',
|
119
|
+
* httpProviderOptions: undefined
|
120
|
+
* }
|
121
|
+
* ```
|
122
|
+
*/
|
123
|
+
get currentProvider(): Web3BaseProvider<API> | undefined;
|
124
|
+
/**
|
125
|
+
* Will set the current provider. (The same as `provider`)
|
126
|
+
*
|
127
|
+
* @param provider - {@link SupportedProviders} The provider to set
|
128
|
+
*
|
129
|
+
* @example
|
130
|
+
* ```ts
|
131
|
+
* const web3Context = new Web3Context("http://localhost:8545");
|
132
|
+
* web3Context.currentProvider = "ws://localhost:8545";
|
133
|
+
* console.log(web3Context.provider);
|
134
|
+
* > WebSocketProvider {
|
135
|
+
* _eventEmitter: EventEmitter {
|
136
|
+
* _events: [Object: null prototype] {},
|
137
|
+
* _eventsCount: 0,
|
138
|
+
* ...
|
139
|
+
* }
|
140
|
+
* ```
|
141
|
+
*/
|
142
|
+
set currentProvider(provider: SupportedProviders<API> | string | undefined);
|
143
|
+
/**
|
144
|
+
* Will return the givenProvider if available.
|
145
|
+
*
|
146
|
+
* 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`.
|
147
|
+
*/
|
148
|
+
get givenProvider(): SupportedProviders<never> | undefined;
|
149
|
+
/**
|
150
|
+
* Will set the provider.
|
151
|
+
*
|
152
|
+
* @param provider - {@link SupportedProviders} The provider to set
|
153
|
+
* @returns Returns true if the provider was set
|
154
|
+
*/
|
155
|
+
setProvider(provider?: SupportedProviders<API> | string): boolean;
|
156
|
+
setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
|
157
|
+
/**
|
158
|
+
* Will return the {@link Web3BatchRequest} constructor.
|
159
|
+
*/
|
160
|
+
get BatchRequest(): new () => Web3BatchRequest;
|
161
|
+
/**
|
162
|
+
* This method allows extending the web3 modules.
|
163
|
+
* 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.
|
164
|
+
*/
|
165
|
+
extend(extendObj: ExtensionObject): this;
|
166
|
+
}
|
167
|
+
/**
|
168
|
+
* Extend this class when creating a plugin that either doesn't require {@link EthExecutionAPI},
|
169
|
+
* or interacts with a RPC node that doesn't fully implement {@link EthExecutionAPI}.
|
170
|
+
*
|
171
|
+
* To add type support for RPC methods to the {@link Web3RequestManager},
|
172
|
+
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
|
173
|
+
*
|
174
|
+
* @example
|
175
|
+
* ```ts
|
176
|
+
* type CustomRpcApi = {
|
177
|
+
* custom_rpc_method: () => string;
|
178
|
+
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
|
179
|
+
* };
|
180
|
+
*
|
181
|
+
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
|
182
|
+
* ```
|
183
|
+
*/
|
184
|
+
export declare abstract class Web3PluginBase<API extends Web3APISpec = Web3APISpec> extends Web3Context<API> {
|
185
|
+
abstract pluginNamespace: string;
|
186
|
+
protected registerNewTransactionType<NewTxTypeClass extends typeof BaseTransaction<unknown>>(type: Numbers, txClass: NewTxTypeClass): void;
|
187
|
+
}
|
188
|
+
/**
|
189
|
+
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
|
190
|
+
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
|
191
|
+
*
|
192
|
+
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
|
193
|
+
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
|
194
|
+
*
|
195
|
+
* @example
|
196
|
+
* ```ts
|
197
|
+
* type CustomRpcApi = {
|
198
|
+
* custom_rpc_method: () => string;
|
199
|
+
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
|
200
|
+
* };
|
201
|
+
*
|
202
|
+
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
|
203
|
+
* ```
|
204
|
+
*/
|
205
|
+
export declare abstract class Web3EthPluginBase<API extends Web3APISpec = unknown> extends Web3PluginBase<API & EthExecutionAPI> {
|
206
|
+
}
|
207
|
+
export declare type TransactionBuilder<API extends Web3APISpec = unknown> = <ReturnType = Transaction>(options: {
|
208
|
+
transaction: Transaction;
|
209
|
+
web3Context: Web3Context<API>;
|
210
|
+
privateKey?: HexString | Uint8Array;
|
211
|
+
fillGasPrice?: boolean;
|
212
|
+
}) => Promise<ReturnType>;
|