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,557 @@
|
|
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
|
+
|
18
|
+
import {
|
19
|
+
Numbers,
|
20
|
+
HexString,
|
21
|
+
BlockNumberOrTag,
|
22
|
+
Common,
|
23
|
+
DEFAULT_RETURN_FORMAT,
|
24
|
+
DataFormat,
|
25
|
+
} from 'web3-types';
|
26
|
+
import { ConfigHardforkMismatchError, ConfigChainMismatchError } from 'web3-errors';
|
27
|
+
import { isNullish, toHex } from 'web3-utils';
|
28
|
+
import { CustomTransactionSchema, TransactionTypeParser } from './types.js';
|
29
|
+
// eslint-disable-next-line import/no-cycle
|
30
|
+
import { TransactionBuilder } from './web3_context.js';
|
31
|
+
import { Web3EventEmitter } from './web3_event_emitter.js';
|
32
|
+
|
33
|
+
// To avoid cycle dependency declare this
|
34
|
+
export interface Web3ConfigOptions {
|
35
|
+
handleRevert: boolean;
|
36
|
+
defaultAccount?: HexString;
|
37
|
+
defaultBlock: BlockNumberOrTag;
|
38
|
+
transactionSendTimeout: number;
|
39
|
+
transactionBlockTimeout: number;
|
40
|
+
transactionConfirmationBlocks: number;
|
41
|
+
transactionPollingInterval: number;
|
42
|
+
transactionPollingTimeout: number;
|
43
|
+
transactionReceiptPollingInterval?: number;
|
44
|
+
transactionConfirmationPollingInterval?: number;
|
45
|
+
blockHeaderTimeout: number;
|
46
|
+
maxListenersWarningThreshold: number;
|
47
|
+
contractDataInputFill: 'data' | 'input' | 'both';
|
48
|
+
defaultNetworkId?: Numbers;
|
49
|
+
defaultChain: string;
|
50
|
+
defaultHardfork: string;
|
51
|
+
ignoreGasPricing: boolean;
|
52
|
+
|
53
|
+
defaultCommon?: Common;
|
54
|
+
defaultTransactionType: Numbers;
|
55
|
+
defaultMaxPriorityFeePerGas: Numbers;
|
56
|
+
enableExperimentalFeatures: {
|
57
|
+
useSubscriptionWhenCheckingBlockTimeout: boolean;
|
58
|
+
useRpcCallSpecification: boolean; // EIP-1474 https://eips.ethereum.org/EIPS/eip-1474
|
59
|
+
// other experimental features...
|
60
|
+
};
|
61
|
+
transactionBuilder?: TransactionBuilder;
|
62
|
+
transactionTypeParser?: TransactionTypeParser;
|
63
|
+
customTransactionSchema?: CustomTransactionSchema;
|
64
|
+
defaultReturnFormat: DataFormat;
|
65
|
+
}
|
66
|
+
|
67
|
+
type ConfigEvent<T, P extends keyof T = keyof T> = P extends unknown
|
68
|
+
? { name: P; oldValue: T[P]; newValue: T[P] }
|
69
|
+
: never;
|
70
|
+
|
71
|
+
export enum Web3ConfigEvent {
|
72
|
+
CONFIG_CHANGE = 'CONFIG_CHANGE',
|
73
|
+
}
|
74
|
+
|
75
|
+
export abstract class Web3Config
|
76
|
+
extends Web3EventEmitter<{ [Web3ConfigEvent.CONFIG_CHANGE]: ConfigEvent<Web3ConfigOptions> }>
|
77
|
+
implements Web3ConfigOptions
|
78
|
+
{
|
79
|
+
public config: Web3ConfigOptions = {
|
80
|
+
handleRevert: false,
|
81
|
+
defaultAccount: undefined,
|
82
|
+
defaultBlock: 'latest',
|
83
|
+
transactionBlockTimeout: 50,
|
84
|
+
transactionConfirmationBlocks: 24,
|
85
|
+
transactionPollingInterval: 1000,
|
86
|
+
transactionPollingTimeout: 750 * 1000,
|
87
|
+
transactionReceiptPollingInterval: undefined,
|
88
|
+
transactionSendTimeout: 750 * 1000,
|
89
|
+
transactionConfirmationPollingInterval: undefined,
|
90
|
+
blockHeaderTimeout: 10,
|
91
|
+
maxListenersWarningThreshold: 100,
|
92
|
+
contractDataInputFill: 'data',
|
93
|
+
defaultNetworkId: undefined,
|
94
|
+
defaultChain: 'mainnet',
|
95
|
+
defaultHardfork: 'london',
|
96
|
+
// TODO - Check if there is a default Common
|
97
|
+
defaultCommon: undefined,
|
98
|
+
defaultTransactionType: '0x2',
|
99
|
+
defaultMaxPriorityFeePerGas: toHex(2500000000),
|
100
|
+
enableExperimentalFeatures: {
|
101
|
+
useSubscriptionWhenCheckingBlockTimeout: false,
|
102
|
+
useRpcCallSpecification: false,
|
103
|
+
},
|
104
|
+
transactionBuilder: undefined,
|
105
|
+
transactionTypeParser: undefined,
|
106
|
+
customTransactionSchema: undefined,
|
107
|
+
defaultReturnFormat: DEFAULT_RETURN_FORMAT,
|
108
|
+
ignoreGasPricing: false,
|
109
|
+
};
|
110
|
+
|
111
|
+
public constructor(options?: Partial<Web3ConfigOptions>) {
|
112
|
+
super();
|
113
|
+
this.setConfig(options ?? {});
|
114
|
+
}
|
115
|
+
|
116
|
+
public setConfig(options: Partial<Web3ConfigOptions>) {
|
117
|
+
// TODO: Improve and add key check
|
118
|
+
const keys = Object.keys(options) as (keyof Web3ConfigOptions)[];
|
119
|
+
for (const key of keys) {
|
120
|
+
this._triggerConfigChange(key, options[key]);
|
121
|
+
|
122
|
+
if (
|
123
|
+
!isNullish(options[key]) &&
|
124
|
+
typeof options[key] === 'number' &&
|
125
|
+
key === 'maxListenersWarningThreshold'
|
126
|
+
) {
|
127
|
+
// additionally set in event emitter
|
128
|
+
this.setMaxListenerWarningThreshold(Number(options[key]));
|
129
|
+
}
|
130
|
+
}
|
131
|
+
Object.assign(this.config, options);
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* The `handleRevert` options property returns the revert reason string if enabled for the following methods:
|
136
|
+
* - web3.eth.sendTransaction()
|
137
|
+
* - web3.eth.call()
|
138
|
+
* - myContract.methods.myMethod().call()
|
139
|
+
* - myContract.methods.myMethod().send()
|
140
|
+
* Default is `false`.
|
141
|
+
*
|
142
|
+
* `Note`: At the moment `handleRevert` is only supported for `sendTransaction` and not for `sendSignedTransaction`
|
143
|
+
*/
|
144
|
+
public get handleRevert() {
|
145
|
+
return this.config.handleRevert;
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Will set the handleRevert
|
150
|
+
*/
|
151
|
+
public set handleRevert(val) {
|
152
|
+
this._triggerConfigChange('handleRevert', val);
|
153
|
+
this.config.handleRevert = val;
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* The `contractDataInputFill` options property will allow you to set the hash of the method signature and encoded parameters to the property
|
158
|
+
* either `data`, `input` or both within your contract.
|
159
|
+
* This will affect the contracts send, call and estimateGas methods
|
160
|
+
* Default is `data`.
|
161
|
+
*/
|
162
|
+
public get contractDataInputFill() {
|
163
|
+
return this.config.contractDataInputFill;
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Will set the contractDataInputFill
|
168
|
+
*/
|
169
|
+
public set contractDataInputFill(val) {
|
170
|
+
this._triggerConfigChange('contractDataInputFill', val);
|
171
|
+
this.config.contractDataInputFill = val;
|
172
|
+
}
|
173
|
+
|
174
|
+
/**
|
175
|
+
* This default address is used as the default `from` property, if no `from` property is specified in for the following methods:
|
176
|
+
* - web3.eth.sendTransaction()
|
177
|
+
* - web3.eth.call()
|
178
|
+
* - myContract.methods.myMethod().call()
|
179
|
+
* - myContract.methods.myMethod().send()
|
180
|
+
*/
|
181
|
+
public get defaultAccount() {
|
182
|
+
return this.config.defaultAccount;
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* Will set the default account.
|
186
|
+
*/
|
187
|
+
public set defaultAccount(val) {
|
188
|
+
this._triggerConfigChange('defaultAccount', val);
|
189
|
+
this.config.defaultAccount = val;
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* 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"`.
|
194
|
+
* - web3.eth.getBalance()
|
195
|
+
* - web3.eth.getCode()
|
196
|
+
* - web3.eth.getTransactionCount()
|
197
|
+
* - web3.eth.getStorageAt()
|
198
|
+
* - web3.eth.call()
|
199
|
+
* - myContract.methods.myMethod().call()
|
200
|
+
*/
|
201
|
+
public get defaultBlock() {
|
202
|
+
return this.config.defaultBlock;
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Will set the default block.
|
207
|
+
*
|
208
|
+
* - A block number
|
209
|
+
* - `"earliest"` - String: The genesis block
|
210
|
+
* - `"latest"` - String: The latest block (current head of the blockchain)
|
211
|
+
* - `"pending"` - String: The currently mined block (including pending transactions)
|
212
|
+
* - `"finalized"` - String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators
|
213
|
+
* - `"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.
|
214
|
+
*/
|
215
|
+
public set defaultBlock(val) {
|
216
|
+
this._triggerConfigChange('defaultBlock', val);
|
217
|
+
this.config.defaultBlock = val;
|
218
|
+
}
|
219
|
+
|
220
|
+
/**
|
221
|
+
* The time used to wait for Ethereum Node to return the sent transaction result.
|
222
|
+
* 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.
|
223
|
+
* Default is `750` seconds (12.5 minutes).
|
224
|
+
*/
|
225
|
+
public get transactionSendTimeout() {
|
226
|
+
return this.config.transactionSendTimeout;
|
227
|
+
}
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Will set the transactionSendTimeout.
|
231
|
+
*/
|
232
|
+
public set transactionSendTimeout(val) {
|
233
|
+
this._triggerConfigChange('transactionSendTimeout', val);
|
234
|
+
this.config.transactionSendTimeout = val;
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* 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.
|
239
|
+
* Default is `50`.
|
240
|
+
*/
|
241
|
+
public get transactionBlockTimeout() {
|
242
|
+
return this.config.transactionBlockTimeout;
|
243
|
+
}
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Will set the transactionBlockTimeout.
|
247
|
+
*/
|
248
|
+
public set transactionBlockTimeout(val) {
|
249
|
+
this._triggerConfigChange('transactionBlockTimeout', val);
|
250
|
+
this.config.transactionBlockTimeout = val;
|
251
|
+
}
|
252
|
+
|
253
|
+
/**
|
254
|
+
* This defines the number of blocks it requires until a transaction is considered confirmed.
|
255
|
+
* Default is `24`.
|
256
|
+
*/
|
257
|
+
public get transactionConfirmationBlocks() {
|
258
|
+
return this.config.transactionConfirmationBlocks;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Will set the transactionConfirmationBlocks.
|
263
|
+
*/
|
264
|
+
public set transactionConfirmationBlocks(val) {
|
265
|
+
this._triggerConfigChange('transactionConfirmationBlocks', val);
|
266
|
+
this.config.transactionConfirmationBlocks = val;
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* 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.
|
271
|
+
* Default is `1000` ms.
|
272
|
+
*/
|
273
|
+
public get transactionPollingInterval() {
|
274
|
+
return this.config.transactionPollingInterval;
|
275
|
+
}
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Will set the transactionPollingInterval.
|
279
|
+
*/
|
280
|
+
public set transactionPollingInterval(val) {
|
281
|
+
this._triggerConfigChange('transactionPollingInterval', val);
|
282
|
+
this.config.transactionPollingInterval = val;
|
283
|
+
|
284
|
+
this.transactionReceiptPollingInterval = val;
|
285
|
+
this.transactionConfirmationPollingInterval = val;
|
286
|
+
}
|
287
|
+
/**
|
288
|
+
* 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.
|
289
|
+
* Default is `750` seconds (12.5 minutes).
|
290
|
+
*/
|
291
|
+
public get transactionPollingTimeout() {
|
292
|
+
return this.config.transactionPollingTimeout;
|
293
|
+
}
|
294
|
+
|
295
|
+
/**
|
296
|
+
* Will set the transactionPollingTimeout.
|
297
|
+
*/
|
298
|
+
public set transactionPollingTimeout(val) {
|
299
|
+
this._triggerConfigChange('transactionPollingTimeout', val);
|
300
|
+
|
301
|
+
this.config.transactionPollingTimeout = val;
|
302
|
+
}
|
303
|
+
|
304
|
+
/**
|
305
|
+
* 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.
|
306
|
+
* Default is `undefined`
|
307
|
+
*/
|
308
|
+
public get transactionReceiptPollingInterval() {
|
309
|
+
return this.config.transactionReceiptPollingInterval;
|
310
|
+
}
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Will set the transactionReceiptPollingInterval
|
314
|
+
*/
|
315
|
+
public set transactionReceiptPollingInterval(val) {
|
316
|
+
this._triggerConfigChange('transactionReceiptPollingInterval', val);
|
317
|
+
this.config.transactionReceiptPollingInterval = val;
|
318
|
+
}
|
319
|
+
|
320
|
+
public get transactionConfirmationPollingInterval() {
|
321
|
+
return this.config.transactionConfirmationPollingInterval;
|
322
|
+
}
|
323
|
+
|
324
|
+
public set transactionConfirmationPollingInterval(val) {
|
325
|
+
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
|
326
|
+
this.config.transactionConfirmationPollingInterval = val;
|
327
|
+
}
|
328
|
+
|
329
|
+
/**
|
330
|
+
* 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.
|
331
|
+
* Default is `10` seconds.
|
332
|
+
*/
|
333
|
+
public get blockHeaderTimeout() {
|
334
|
+
return this.config.blockHeaderTimeout;
|
335
|
+
}
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Will set the blockHeaderTimeout
|
339
|
+
*/
|
340
|
+
public set blockHeaderTimeout(val) {
|
341
|
+
this._triggerConfigChange('blockHeaderTimeout', val);
|
342
|
+
|
343
|
+
this.config.blockHeaderTimeout = val;
|
344
|
+
}
|
345
|
+
|
346
|
+
/**
|
347
|
+
* 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.
|
348
|
+
* Default is `false` for every feature.
|
349
|
+
*/
|
350
|
+
public get enableExperimentalFeatures() {
|
351
|
+
return this.config.enableExperimentalFeatures;
|
352
|
+
}
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Will set the enableExperimentalFeatures
|
356
|
+
*/
|
357
|
+
public set enableExperimentalFeatures(val) {
|
358
|
+
this._triggerConfigChange('enableExperimentalFeatures', val);
|
359
|
+
|
360
|
+
this.config.enableExperimentalFeatures = val;
|
361
|
+
}
|
362
|
+
|
363
|
+
public get maxListenersWarningThreshold() {
|
364
|
+
return this.config.maxListenersWarningThreshold;
|
365
|
+
}
|
366
|
+
|
367
|
+
public set maxListenersWarningThreshold(val) {
|
368
|
+
this._triggerConfigChange('maxListenersWarningThreshold', val);
|
369
|
+
this.setMaxListenerWarningThreshold(val);
|
370
|
+
this.config.maxListenersWarningThreshold = val;
|
371
|
+
}
|
372
|
+
|
373
|
+
public get defaultReturnFormat() {
|
374
|
+
return this.config.defaultReturnFormat;
|
375
|
+
}
|
376
|
+
public set defaultReturnFormat(val) {
|
377
|
+
this._triggerConfigChange('defaultReturnFormat', val);
|
378
|
+
|
379
|
+
this.config.defaultReturnFormat = val;
|
380
|
+
}
|
381
|
+
|
382
|
+
public get defaultNetworkId() {
|
383
|
+
return this.config.defaultNetworkId;
|
384
|
+
}
|
385
|
+
|
386
|
+
public set defaultNetworkId(val) {
|
387
|
+
this._triggerConfigChange('defaultNetworkId', val);
|
388
|
+
|
389
|
+
this.config.defaultNetworkId = val;
|
390
|
+
}
|
391
|
+
|
392
|
+
public get defaultChain() {
|
393
|
+
return this.config.defaultChain;
|
394
|
+
}
|
395
|
+
|
396
|
+
public set defaultChain(val) {
|
397
|
+
if (
|
398
|
+
!isNullish(this.config.defaultCommon) &&
|
399
|
+
!isNullish(this.config.defaultCommon.baseChain) &&
|
400
|
+
val !== this.config.defaultCommon.baseChain
|
401
|
+
)
|
402
|
+
throw new ConfigChainMismatchError(this.config.defaultChain, val);
|
403
|
+
|
404
|
+
this._triggerConfigChange('defaultChain', val);
|
405
|
+
|
406
|
+
this.config.defaultChain = val;
|
407
|
+
}
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Will return the default hardfork. Default is `london`
|
411
|
+
* The default hardfork property can be one of the following:
|
412
|
+
* - `chainstart`
|
413
|
+
* - `homestead`
|
414
|
+
* - `dao`
|
415
|
+
* - `tangerineWhistle`
|
416
|
+
* - `spuriousDragon`
|
417
|
+
* - `byzantium`
|
418
|
+
* - `constantinople`
|
419
|
+
* - `petersburg`
|
420
|
+
* - `istanbul`
|
421
|
+
* - `berlin`
|
422
|
+
* - `london`
|
423
|
+
* - 'arrowGlacier',
|
424
|
+
* - 'tangerineWhistle',
|
425
|
+
* - 'muirGlacier'
|
426
|
+
*
|
427
|
+
*/
|
428
|
+
public get defaultHardfork() {
|
429
|
+
return this.config.defaultHardfork;
|
430
|
+
}
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Will set the default hardfork.
|
434
|
+
*
|
435
|
+
*/
|
436
|
+
public set defaultHardfork(val) {
|
437
|
+
if (
|
438
|
+
!isNullish(this.config.defaultCommon) &&
|
439
|
+
!isNullish(this.config.defaultCommon.hardfork) &&
|
440
|
+
val !== this.config.defaultCommon.hardfork
|
441
|
+
)
|
442
|
+
throw new ConfigHardforkMismatchError(this.config.defaultCommon.hardfork, val);
|
443
|
+
this._triggerConfigChange('defaultHardfork', val);
|
444
|
+
|
445
|
+
this.config.defaultHardfork = val;
|
446
|
+
}
|
447
|
+
|
448
|
+
/**
|
449
|
+
*
|
450
|
+
* Will get the default common property
|
451
|
+
* The default common property does contain the following Common object:
|
452
|
+
* - `customChain` - `Object`: The custom chain properties
|
453
|
+
* - `name` - `string`: (optional) The name of the chain
|
454
|
+
* - `networkId` - `number`: Network ID of the custom chain
|
455
|
+
* - `chainId` - `number`: Chain ID of the custom chain
|
456
|
+
* - `baseChain` - `string`: (optional) mainnet, goerli, kovan, rinkeby, or ropsten
|
457
|
+
* - `hardfork` - `string`: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london
|
458
|
+
* Default is `undefined`.
|
459
|
+
*
|
460
|
+
*/
|
461
|
+
public get defaultCommon() {
|
462
|
+
return this.config.defaultCommon;
|
463
|
+
}
|
464
|
+
|
465
|
+
/**
|
466
|
+
* Will set the default common property
|
467
|
+
*
|
468
|
+
*/
|
469
|
+
public set defaultCommon(val: Common | undefined) {
|
470
|
+
// validation check if default hardfork is set and matches defaultCommon hardfork
|
471
|
+
if (
|
472
|
+
!isNullish(this.config.defaultHardfork) &&
|
473
|
+
!isNullish(val) &&
|
474
|
+
!isNullish(val.hardfork) &&
|
475
|
+
this.config.defaultHardfork !== val.hardfork
|
476
|
+
)
|
477
|
+
throw new ConfigHardforkMismatchError(this.config.defaultHardfork, val.hardfork);
|
478
|
+
if (
|
479
|
+
!isNullish(this.config.defaultChain) &&
|
480
|
+
!isNullish(val) &&
|
481
|
+
!isNullish(val.baseChain) &&
|
482
|
+
this.config.defaultChain !== val.baseChain
|
483
|
+
)
|
484
|
+
throw new ConfigChainMismatchError(this.config.defaultChain, val.baseChain);
|
485
|
+
this._triggerConfigChange('defaultCommon', val);
|
486
|
+
|
487
|
+
this.config.defaultCommon = val;
|
488
|
+
}
|
489
|
+
|
490
|
+
/**
|
491
|
+
* Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object.
|
492
|
+
* Useful when you want wallets to handle gas pricing.
|
493
|
+
*/
|
494
|
+
public get ignoreGasPricing() {
|
495
|
+
return this.config.ignoreGasPricing;
|
496
|
+
}
|
497
|
+
public set ignoreGasPricing(val) {
|
498
|
+
this._triggerConfigChange('ignoreGasPricing', val);
|
499
|
+
this.config.ignoreGasPricing = val;
|
500
|
+
}
|
501
|
+
public get defaultTransactionType() {
|
502
|
+
return this.config.defaultTransactionType;
|
503
|
+
}
|
504
|
+
|
505
|
+
public set defaultTransactionType(val) {
|
506
|
+
this._triggerConfigChange('defaultTransactionType', val);
|
507
|
+
|
508
|
+
this.config.defaultTransactionType = val;
|
509
|
+
}
|
510
|
+
|
511
|
+
public get defaultMaxPriorityFeePerGas() {
|
512
|
+
return this.config.defaultMaxPriorityFeePerGas;
|
513
|
+
}
|
514
|
+
|
515
|
+
public set defaultMaxPriorityFeePerGas(val) {
|
516
|
+
this._triggerConfigChange('defaultMaxPriorityFeePerGas', val);
|
517
|
+
this.config.defaultMaxPriorityFeePerGas = val;
|
518
|
+
}
|
519
|
+
|
520
|
+
public get transactionBuilder() {
|
521
|
+
return this.config.transactionBuilder;
|
522
|
+
}
|
523
|
+
|
524
|
+
public set transactionBuilder(val) {
|
525
|
+
this._triggerConfigChange('transactionBuilder', val);
|
526
|
+
this.config.transactionBuilder = val;
|
527
|
+
}
|
528
|
+
|
529
|
+
public get transactionTypeParser() {
|
530
|
+
return this.config.transactionTypeParser;
|
531
|
+
}
|
532
|
+
|
533
|
+
public set transactionTypeParser(val) {
|
534
|
+
this._triggerConfigChange('transactionTypeParser', val);
|
535
|
+
this.config.transactionTypeParser = val;
|
536
|
+
}
|
537
|
+
|
538
|
+
public get customTransactionSchema(): CustomTransactionSchema | undefined {
|
539
|
+
return this.config.customTransactionSchema;
|
540
|
+
}
|
541
|
+
|
542
|
+
public set customTransactionSchema(schema: CustomTransactionSchema | undefined) {
|
543
|
+
this._triggerConfigChange('customTransactionSchema', schema);
|
544
|
+
this.config.customTransactionSchema = schema;
|
545
|
+
}
|
546
|
+
|
547
|
+
private _triggerConfigChange<K extends keyof Web3ConfigOptions>(
|
548
|
+
config: K,
|
549
|
+
newValue: Web3ConfigOptions[K],
|
550
|
+
) {
|
551
|
+
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
|
552
|
+
name: config,
|
553
|
+
oldValue: this.config[config],
|
554
|
+
newValue,
|
555
|
+
} as ConfigEvent<Web3ConfigOptions>);
|
556
|
+
}
|
557
|
+
}
|