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
package/lib/esm/types.js
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
+
export {};
|
18
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE"}
|
package/lib/esm/utils.js
ADDED
@@ -0,0 +1,47 @@
|
|
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 { Web3BaseProvider, } from 'web3-types';
|
18
|
+
export const isWeb3Provider = (provider) => Web3BaseProvider.isWeb3Provider(provider);
|
19
|
+
export const isMetaMaskProvider = (provider) => typeof provider !== 'string' &&
|
20
|
+
'request' in provider &&
|
21
|
+
provider.request.constructor.name === 'AsyncFunction' &&
|
22
|
+
'isMetaMask' in provider &&
|
23
|
+
provider.isMetaMask;
|
24
|
+
export const isLegacyRequestProvider = (provider) => typeof provider !== 'string' &&
|
25
|
+
'request' in provider &&
|
26
|
+
provider.request.constructor.name === 'Function';
|
27
|
+
export const isEIP1193Provider = (provider) => typeof provider !== 'string' &&
|
28
|
+
'request' in provider &&
|
29
|
+
provider.request.constructor.name === 'AsyncFunction';
|
30
|
+
export const isLegacySendProvider = (provider) => typeof provider !== 'string' && 'send' in provider;
|
31
|
+
export const isLegacySendAsyncProvider = (provider) => typeof provider !== 'string' && 'sendAsync' in provider;
|
32
|
+
export const isSupportedProvider = (provider) => provider &&
|
33
|
+
(isWeb3Provider(provider) ||
|
34
|
+
isEIP1193Provider(provider) ||
|
35
|
+
isLegacyRequestProvider(provider) ||
|
36
|
+
isLegacySendAsyncProvider(provider) ||
|
37
|
+
isLegacySendProvider(provider));
|
38
|
+
export const isSupportSubscriptions = (provider) => {
|
39
|
+
if (provider && 'supportsSubscriptions' in provider) {
|
40
|
+
return provider.supportsSubscriptions();
|
41
|
+
}
|
42
|
+
if (provider && typeof provider !== 'string' && 'on' in provider) {
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
return false;
|
46
|
+
};
|
47
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAON,gBAAgB,GAEhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,QAAiC,EACG,EAAE,CAAC,gBAAgB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,QAAiC,EACG,EAAE,CACtC,OAAO,QAAQ,KAAK,QAAQ;IAC5B,SAAS,IAAI,QAAQ;IACrB,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe;IACrD,YAAY,IAAI,QAAQ;IACxB,QAAQ,CAAC,UAAU,CAAC;AAErB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACtC,QAAiC,EACG,EAAE,CACtC,OAAO,QAAQ,KAAK,QAAQ;IAC5B,SAAS,IAAI,QAAQ;IACrB,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,QAAiC,EACE,EAAE,CACrC,OAAO,QAAQ,KAAK,QAAQ;IAC5B,SAAS,IAAI,QAAQ;IACrB,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,QAAiC,EACA,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,QAAQ,CAAC;AAExF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACxC,QAAiC,EACK,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,WAAW,IAAI,QAAQ,CAAC;AAElG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAClC,QAAiC,EACK,EAAE,CACxC,QAAQ;IACR,CAAC,cAAc,CAAC,QAAQ,CAAC;QACxB,iBAAiB,CAAC,QAAQ,CAAC;QAC3B,uBAAuB,CAAC,QAAQ,CAAC;QACjC,yBAAyB,CAAC,QAAQ,CAAC;QACnC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACrC,QAAiC,EACvB,EAAE;IACZ,IAAI,QAAQ,IAAI,uBAAuB,IAAI,QAAQ,EAAE;QACpD,OAAO,QAAQ,CAAC,qBAAqB,EAAE,CAAC;KACxC;IAED,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,IAAI,IAAI,QAAQ,EAAE;QACjE,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
|
@@ -0,0 +1,102 @@
|
|
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
|
+
import { jsonRpc, Web3DeferredPromise } from 'web3-utils';
|
27
|
+
import { OperationAbortError, OperationTimeoutError, ResponseError } from 'web3-errors';
|
28
|
+
export const DEFAULT_BATCH_REQUEST_TIMEOUT = 1000;
|
29
|
+
export class Web3BatchRequest {
|
30
|
+
constructor(requestManager) {
|
31
|
+
this._requestManager = requestManager;
|
32
|
+
this._requests = new Map();
|
33
|
+
}
|
34
|
+
get requests() {
|
35
|
+
return [...this._requests.values()].map(r => r.payload);
|
36
|
+
}
|
37
|
+
add(request) {
|
38
|
+
const payload = jsonRpc.toPayload(request);
|
39
|
+
const promise = new Web3DeferredPromise();
|
40
|
+
this._requests.set(payload.id, { payload, promise });
|
41
|
+
return promise;
|
42
|
+
}
|
43
|
+
// eslint-disable-next-line class-methods-use-this
|
44
|
+
execute(options) {
|
45
|
+
var _a;
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
47
|
+
if (this.requests.length === 0) {
|
48
|
+
return Promise.resolve([]);
|
49
|
+
}
|
50
|
+
const request = new Web3DeferredPromise({
|
51
|
+
timeout: (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : DEFAULT_BATCH_REQUEST_TIMEOUT,
|
52
|
+
eagerStart: true,
|
53
|
+
timeoutMessage: 'Batch request timeout',
|
54
|
+
});
|
55
|
+
this._processBatchRequest(request).catch(err => request.reject(err));
|
56
|
+
request.catch((err) => {
|
57
|
+
if (err instanceof OperationTimeoutError) {
|
58
|
+
this._abortAllRequests('Batch request timeout');
|
59
|
+
}
|
60
|
+
request.reject(err);
|
61
|
+
});
|
62
|
+
return request;
|
63
|
+
});
|
64
|
+
}
|
65
|
+
_processBatchRequest(promise) {
|
66
|
+
var _a, _b;
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
68
|
+
const response = yield this._requestManager.sendBatch([...this._requests.values()].map(r => r.payload));
|
69
|
+
if (response.length !== this._requests.size) {
|
70
|
+
this._abortAllRequests('Invalid batch response');
|
71
|
+
throw new ResponseError(response, `Batch request size mismatch the results size. Requests: ${this._requests.size}, Responses: ${response.length}`);
|
72
|
+
}
|
73
|
+
const requestIds = this.requests
|
74
|
+
.map(r => r.id)
|
75
|
+
.map(Number)
|
76
|
+
.sort((a, b) => a - b);
|
77
|
+
const responseIds = response
|
78
|
+
.map(r => r.id)
|
79
|
+
.map(Number)
|
80
|
+
.sort((a, b) => a - b);
|
81
|
+
if (JSON.stringify(requestIds) !== JSON.stringify(responseIds)) {
|
82
|
+
this._abortAllRequests('Invalid batch response');
|
83
|
+
throw new ResponseError(response, `Batch request mismatch the results. Requests: [${requestIds.join()}], Responses: [${responseIds.join()}]`);
|
84
|
+
}
|
85
|
+
for (const res of response) {
|
86
|
+
if (jsonRpc.isResponseWithResult(res)) {
|
87
|
+
(_a = this._requests.get(res.id)) === null || _a === void 0 ? void 0 : _a.promise.resolve(res.result);
|
88
|
+
}
|
89
|
+
else if (jsonRpc.isResponseWithError(res)) {
|
90
|
+
(_b = this._requests.get(res.id)) === null || _b === void 0 ? void 0 : _b.promise.reject(res.error);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
promise.resolve(response);
|
94
|
+
});
|
95
|
+
}
|
96
|
+
_abortAllRequests(msg) {
|
97
|
+
for (const { promise } of this._requests.values()) {
|
98
|
+
promise.reject(new OperationAbortError(msg));
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
//# sourceMappingURL=web3_batch_request.js.map
|
@@ -0,0 +1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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 { DEFAULT_RETURN_FORMAT, } from 'web3-types';
|
18
|
+
import { ConfigHardforkMismatchError, ConfigChainMismatchError } from 'web3-errors';
|
19
|
+
import { isNullish, toHex } from 'web3-utils';
|
20
|
+
import { Web3EventEmitter } from './web3_event_emitter.js';
|
21
|
+
export var Web3ConfigEvent;
|
22
|
+
(function (Web3ConfigEvent) {
|
23
|
+
Web3ConfigEvent["CONFIG_CHANGE"] = "CONFIG_CHANGE";
|
24
|
+
})(Web3ConfigEvent || (Web3ConfigEvent = {}));
|
25
|
+
export class Web3Config extends Web3EventEmitter {
|
26
|
+
constructor(options) {
|
27
|
+
super();
|
28
|
+
this.config = {
|
29
|
+
handleRevert: false,
|
30
|
+
defaultAccount: undefined,
|
31
|
+
defaultBlock: 'latest',
|
32
|
+
transactionBlockTimeout: 50,
|
33
|
+
transactionConfirmationBlocks: 24,
|
34
|
+
transactionPollingInterval: 1000,
|
35
|
+
transactionPollingTimeout: 750 * 1000,
|
36
|
+
transactionReceiptPollingInterval: undefined,
|
37
|
+
transactionSendTimeout: 750 * 1000,
|
38
|
+
transactionConfirmationPollingInterval: undefined,
|
39
|
+
blockHeaderTimeout: 10,
|
40
|
+
maxListenersWarningThreshold: 100,
|
41
|
+
contractDataInputFill: 'data',
|
42
|
+
defaultNetworkId: undefined,
|
43
|
+
defaultChain: 'mainnet',
|
44
|
+
defaultHardfork: 'london',
|
45
|
+
// TODO - Check if there is a default Common
|
46
|
+
defaultCommon: undefined,
|
47
|
+
defaultTransactionType: '0x2',
|
48
|
+
defaultMaxPriorityFeePerGas: toHex(2500000000),
|
49
|
+
enableExperimentalFeatures: {
|
50
|
+
useSubscriptionWhenCheckingBlockTimeout: false,
|
51
|
+
useRpcCallSpecification: false,
|
52
|
+
},
|
53
|
+
transactionBuilder: undefined,
|
54
|
+
transactionTypeParser: undefined,
|
55
|
+
customTransactionSchema: undefined,
|
56
|
+
defaultReturnFormat: DEFAULT_RETURN_FORMAT,
|
57
|
+
ignoreGasPricing: false,
|
58
|
+
};
|
59
|
+
this.setConfig(options !== null && options !== void 0 ? options : {});
|
60
|
+
}
|
61
|
+
setConfig(options) {
|
62
|
+
// TODO: Improve and add key check
|
63
|
+
const keys = Object.keys(options);
|
64
|
+
for (const key of keys) {
|
65
|
+
this._triggerConfigChange(key, options[key]);
|
66
|
+
if (!isNullish(options[key]) &&
|
67
|
+
typeof options[key] === 'number' &&
|
68
|
+
key === 'maxListenersWarningThreshold') {
|
69
|
+
// additionally set in event emitter
|
70
|
+
this.setMaxListenerWarningThreshold(Number(options[key]));
|
71
|
+
}
|
72
|
+
}
|
73
|
+
Object.assign(this.config, options);
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* The `handleRevert` options property returns the revert reason string if enabled for the following methods:
|
77
|
+
* - web3.eth.sendTransaction()
|
78
|
+
* - web3.eth.call()
|
79
|
+
* - myContract.methods.myMethod().call()
|
80
|
+
* - myContract.methods.myMethod().send()
|
81
|
+
* Default is `false`.
|
82
|
+
*
|
83
|
+
* `Note`: At the moment `handleRevert` is only supported for `sendTransaction` and not for `sendSignedTransaction`
|
84
|
+
*/
|
85
|
+
get handleRevert() {
|
86
|
+
return this.config.handleRevert;
|
87
|
+
}
|
88
|
+
/**
|
89
|
+
* Will set the handleRevert
|
90
|
+
*/
|
91
|
+
set handleRevert(val) {
|
92
|
+
this._triggerConfigChange('handleRevert', val);
|
93
|
+
this.config.handleRevert = val;
|
94
|
+
}
|
95
|
+
/**
|
96
|
+
* The `contractDataInputFill` options property will allow you to set the hash of the method signature and encoded parameters to the property
|
97
|
+
* either `data`, `input` or both within your contract.
|
98
|
+
* This will affect the contracts send, call and estimateGas methods
|
99
|
+
* Default is `data`.
|
100
|
+
*/
|
101
|
+
get contractDataInputFill() {
|
102
|
+
return this.config.contractDataInputFill;
|
103
|
+
}
|
104
|
+
/**
|
105
|
+
* Will set the contractDataInputFill
|
106
|
+
*/
|
107
|
+
set contractDataInputFill(val) {
|
108
|
+
this._triggerConfigChange('contractDataInputFill', val);
|
109
|
+
this.config.contractDataInputFill = val;
|
110
|
+
}
|
111
|
+
/**
|
112
|
+
* This default address is used as the default `from` property, if no `from` property is specified in for the following methods:
|
113
|
+
* - web3.eth.sendTransaction()
|
114
|
+
* - web3.eth.call()
|
115
|
+
* - myContract.methods.myMethod().call()
|
116
|
+
* - myContract.methods.myMethod().send()
|
117
|
+
*/
|
118
|
+
get defaultAccount() {
|
119
|
+
return this.config.defaultAccount;
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Will set the default account.
|
123
|
+
*/
|
124
|
+
set defaultAccount(val) {
|
125
|
+
this._triggerConfigChange('defaultAccount', val);
|
126
|
+
this.config.defaultAccount = val;
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* 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"`.
|
130
|
+
* - web3.eth.getBalance()
|
131
|
+
* - web3.eth.getCode()
|
132
|
+
* - web3.eth.getTransactionCount()
|
133
|
+
* - web3.eth.getStorageAt()
|
134
|
+
* - web3.eth.call()
|
135
|
+
* - myContract.methods.myMethod().call()
|
136
|
+
*/
|
137
|
+
get defaultBlock() {
|
138
|
+
return this.config.defaultBlock;
|
139
|
+
}
|
140
|
+
/**
|
141
|
+
* Will set the default block.
|
142
|
+
*
|
143
|
+
* - A block number
|
144
|
+
* - `"earliest"` - String: The genesis block
|
145
|
+
* - `"latest"` - String: The latest block (current head of the blockchain)
|
146
|
+
* - `"pending"` - String: The currently mined block (including pending transactions)
|
147
|
+
* - `"finalized"` - String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators
|
148
|
+
* - `"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.
|
149
|
+
*/
|
150
|
+
set defaultBlock(val) {
|
151
|
+
this._triggerConfigChange('defaultBlock', val);
|
152
|
+
this.config.defaultBlock = val;
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* The time used to wait for Ethereum Node to return the sent transaction result.
|
156
|
+
* 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.
|
157
|
+
* Default is `750` seconds (12.5 minutes).
|
158
|
+
*/
|
159
|
+
get transactionSendTimeout() {
|
160
|
+
return this.config.transactionSendTimeout;
|
161
|
+
}
|
162
|
+
/**
|
163
|
+
* Will set the transactionSendTimeout.
|
164
|
+
*/
|
165
|
+
set transactionSendTimeout(val) {
|
166
|
+
this._triggerConfigChange('transactionSendTimeout', val);
|
167
|
+
this.config.transactionSendTimeout = val;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* 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.
|
171
|
+
* Default is `50`.
|
172
|
+
*/
|
173
|
+
get transactionBlockTimeout() {
|
174
|
+
return this.config.transactionBlockTimeout;
|
175
|
+
}
|
176
|
+
/**
|
177
|
+
* Will set the transactionBlockTimeout.
|
178
|
+
*/
|
179
|
+
set transactionBlockTimeout(val) {
|
180
|
+
this._triggerConfigChange('transactionBlockTimeout', val);
|
181
|
+
this.config.transactionBlockTimeout = val;
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* This defines the number of blocks it requires until a transaction is considered confirmed.
|
185
|
+
* Default is `24`.
|
186
|
+
*/
|
187
|
+
get transactionConfirmationBlocks() {
|
188
|
+
return this.config.transactionConfirmationBlocks;
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Will set the transactionConfirmationBlocks.
|
192
|
+
*/
|
193
|
+
set transactionConfirmationBlocks(val) {
|
194
|
+
this._triggerConfigChange('transactionConfirmationBlocks', val);
|
195
|
+
this.config.transactionConfirmationBlocks = val;
|
196
|
+
}
|
197
|
+
/**
|
198
|
+
* 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.
|
199
|
+
* Default is `1000` ms.
|
200
|
+
*/
|
201
|
+
get transactionPollingInterval() {
|
202
|
+
return this.config.transactionPollingInterval;
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* Will set the transactionPollingInterval.
|
206
|
+
*/
|
207
|
+
set transactionPollingInterval(val) {
|
208
|
+
this._triggerConfigChange('transactionPollingInterval', val);
|
209
|
+
this.config.transactionPollingInterval = val;
|
210
|
+
this.transactionReceiptPollingInterval = val;
|
211
|
+
this.transactionConfirmationPollingInterval = val;
|
212
|
+
}
|
213
|
+
/**
|
214
|
+
* 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.
|
215
|
+
* Default is `750` seconds (12.5 minutes).
|
216
|
+
*/
|
217
|
+
get transactionPollingTimeout() {
|
218
|
+
return this.config.transactionPollingTimeout;
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Will set the transactionPollingTimeout.
|
222
|
+
*/
|
223
|
+
set transactionPollingTimeout(val) {
|
224
|
+
this._triggerConfigChange('transactionPollingTimeout', val);
|
225
|
+
this.config.transactionPollingTimeout = val;
|
226
|
+
}
|
227
|
+
/**
|
228
|
+
* 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.
|
229
|
+
* Default is `undefined`
|
230
|
+
*/
|
231
|
+
get transactionReceiptPollingInterval() {
|
232
|
+
return this.config.transactionReceiptPollingInterval;
|
233
|
+
}
|
234
|
+
/**
|
235
|
+
* Will set the transactionReceiptPollingInterval
|
236
|
+
*/
|
237
|
+
set transactionReceiptPollingInterval(val) {
|
238
|
+
this._triggerConfigChange('transactionReceiptPollingInterval', val);
|
239
|
+
this.config.transactionReceiptPollingInterval = val;
|
240
|
+
}
|
241
|
+
get transactionConfirmationPollingInterval() {
|
242
|
+
return this.config.transactionConfirmationPollingInterval;
|
243
|
+
}
|
244
|
+
set transactionConfirmationPollingInterval(val) {
|
245
|
+
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
|
246
|
+
this.config.transactionConfirmationPollingInterval = val;
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* 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.
|
250
|
+
* Default is `10` seconds.
|
251
|
+
*/
|
252
|
+
get blockHeaderTimeout() {
|
253
|
+
return this.config.blockHeaderTimeout;
|
254
|
+
}
|
255
|
+
/**
|
256
|
+
* Will set the blockHeaderTimeout
|
257
|
+
*/
|
258
|
+
set blockHeaderTimeout(val) {
|
259
|
+
this._triggerConfigChange('blockHeaderTimeout', val);
|
260
|
+
this.config.blockHeaderTimeout = val;
|
261
|
+
}
|
262
|
+
/**
|
263
|
+
* 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.
|
264
|
+
* Default is `false` for every feature.
|
265
|
+
*/
|
266
|
+
get enableExperimentalFeatures() {
|
267
|
+
return this.config.enableExperimentalFeatures;
|
268
|
+
}
|
269
|
+
/**
|
270
|
+
* Will set the enableExperimentalFeatures
|
271
|
+
*/
|
272
|
+
set enableExperimentalFeatures(val) {
|
273
|
+
this._triggerConfigChange('enableExperimentalFeatures', val);
|
274
|
+
this.config.enableExperimentalFeatures = val;
|
275
|
+
}
|
276
|
+
get maxListenersWarningThreshold() {
|
277
|
+
return this.config.maxListenersWarningThreshold;
|
278
|
+
}
|
279
|
+
set maxListenersWarningThreshold(val) {
|
280
|
+
this._triggerConfigChange('maxListenersWarningThreshold', val);
|
281
|
+
this.setMaxListenerWarningThreshold(val);
|
282
|
+
this.config.maxListenersWarningThreshold = val;
|
283
|
+
}
|
284
|
+
get defaultReturnFormat() {
|
285
|
+
return this.config.defaultReturnFormat;
|
286
|
+
}
|
287
|
+
set defaultReturnFormat(val) {
|
288
|
+
this._triggerConfigChange('defaultReturnFormat', val);
|
289
|
+
this.config.defaultReturnFormat = val;
|
290
|
+
}
|
291
|
+
get defaultNetworkId() {
|
292
|
+
return this.config.defaultNetworkId;
|
293
|
+
}
|
294
|
+
set defaultNetworkId(val) {
|
295
|
+
this._triggerConfigChange('defaultNetworkId', val);
|
296
|
+
this.config.defaultNetworkId = val;
|
297
|
+
}
|
298
|
+
get defaultChain() {
|
299
|
+
return this.config.defaultChain;
|
300
|
+
}
|
301
|
+
set defaultChain(val) {
|
302
|
+
if (!isNullish(this.config.defaultCommon) &&
|
303
|
+
!isNullish(this.config.defaultCommon.baseChain) &&
|
304
|
+
val !== this.config.defaultCommon.baseChain)
|
305
|
+
throw new ConfigChainMismatchError(this.config.defaultChain, val);
|
306
|
+
this._triggerConfigChange('defaultChain', val);
|
307
|
+
this.config.defaultChain = val;
|
308
|
+
}
|
309
|
+
/**
|
310
|
+
* Will return the default hardfork. Default is `london`
|
311
|
+
* The default hardfork property can be one of the following:
|
312
|
+
* - `chainstart`
|
313
|
+
* - `homestead`
|
314
|
+
* - `dao`
|
315
|
+
* - `tangerineWhistle`
|
316
|
+
* - `spuriousDragon`
|
317
|
+
* - `byzantium`
|
318
|
+
* - `constantinople`
|
319
|
+
* - `petersburg`
|
320
|
+
* - `istanbul`
|
321
|
+
* - `berlin`
|
322
|
+
* - `london`
|
323
|
+
* - 'arrowGlacier',
|
324
|
+
* - 'tangerineWhistle',
|
325
|
+
* - 'muirGlacier'
|
326
|
+
*
|
327
|
+
*/
|
328
|
+
get defaultHardfork() {
|
329
|
+
return this.config.defaultHardfork;
|
330
|
+
}
|
331
|
+
/**
|
332
|
+
* Will set the default hardfork.
|
333
|
+
*
|
334
|
+
*/
|
335
|
+
set defaultHardfork(val) {
|
336
|
+
if (!isNullish(this.config.defaultCommon) &&
|
337
|
+
!isNullish(this.config.defaultCommon.hardfork) &&
|
338
|
+
val !== this.config.defaultCommon.hardfork)
|
339
|
+
throw new ConfigHardforkMismatchError(this.config.defaultCommon.hardfork, val);
|
340
|
+
this._triggerConfigChange('defaultHardfork', val);
|
341
|
+
this.config.defaultHardfork = val;
|
342
|
+
}
|
343
|
+
/**
|
344
|
+
*
|
345
|
+
* Will get the default common property
|
346
|
+
* The default common property does contain the following Common object:
|
347
|
+
* - `customChain` - `Object`: The custom chain properties
|
348
|
+
* - `name` - `string`: (optional) The name of the chain
|
349
|
+
* - `networkId` - `number`: Network ID of the custom chain
|
350
|
+
* - `chainId` - `number`: Chain ID of the custom chain
|
351
|
+
* - `baseChain` - `string`: (optional) mainnet, goerli, kovan, rinkeby, or ropsten
|
352
|
+
* - `hardfork` - `string`: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london
|
353
|
+
* Default is `undefined`.
|
354
|
+
*
|
355
|
+
*/
|
356
|
+
get defaultCommon() {
|
357
|
+
return this.config.defaultCommon;
|
358
|
+
}
|
359
|
+
/**
|
360
|
+
* Will set the default common property
|
361
|
+
*
|
362
|
+
*/
|
363
|
+
set defaultCommon(val) {
|
364
|
+
// validation check if default hardfork is set and matches defaultCommon hardfork
|
365
|
+
if (!isNullish(this.config.defaultHardfork) &&
|
366
|
+
!isNullish(val) &&
|
367
|
+
!isNullish(val.hardfork) &&
|
368
|
+
this.config.defaultHardfork !== val.hardfork)
|
369
|
+
throw new ConfigHardforkMismatchError(this.config.defaultHardfork, val.hardfork);
|
370
|
+
if (!isNullish(this.config.defaultChain) &&
|
371
|
+
!isNullish(val) &&
|
372
|
+
!isNullish(val.baseChain) &&
|
373
|
+
this.config.defaultChain !== val.baseChain)
|
374
|
+
throw new ConfigChainMismatchError(this.config.defaultChain, val.baseChain);
|
375
|
+
this._triggerConfigChange('defaultCommon', val);
|
376
|
+
this.config.defaultCommon = val;
|
377
|
+
}
|
378
|
+
/**
|
379
|
+
* Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object.
|
380
|
+
* Useful when you want wallets to handle gas pricing.
|
381
|
+
*/
|
382
|
+
get ignoreGasPricing() {
|
383
|
+
return this.config.ignoreGasPricing;
|
384
|
+
}
|
385
|
+
set ignoreGasPricing(val) {
|
386
|
+
this._triggerConfigChange('ignoreGasPricing', val);
|
387
|
+
this.config.ignoreGasPricing = val;
|
388
|
+
}
|
389
|
+
get defaultTransactionType() {
|
390
|
+
return this.config.defaultTransactionType;
|
391
|
+
}
|
392
|
+
set defaultTransactionType(val) {
|
393
|
+
this._triggerConfigChange('defaultTransactionType', val);
|
394
|
+
this.config.defaultTransactionType = val;
|
395
|
+
}
|
396
|
+
get defaultMaxPriorityFeePerGas() {
|
397
|
+
return this.config.defaultMaxPriorityFeePerGas;
|
398
|
+
}
|
399
|
+
set defaultMaxPriorityFeePerGas(val) {
|
400
|
+
this._triggerConfigChange('defaultMaxPriorityFeePerGas', val);
|
401
|
+
this.config.defaultMaxPriorityFeePerGas = val;
|
402
|
+
}
|
403
|
+
get transactionBuilder() {
|
404
|
+
return this.config.transactionBuilder;
|
405
|
+
}
|
406
|
+
set transactionBuilder(val) {
|
407
|
+
this._triggerConfigChange('transactionBuilder', val);
|
408
|
+
this.config.transactionBuilder = val;
|
409
|
+
}
|
410
|
+
get transactionTypeParser() {
|
411
|
+
return this.config.transactionTypeParser;
|
412
|
+
}
|
413
|
+
set transactionTypeParser(val) {
|
414
|
+
this._triggerConfigChange('transactionTypeParser', val);
|
415
|
+
this.config.transactionTypeParser = val;
|
416
|
+
}
|
417
|
+
get customTransactionSchema() {
|
418
|
+
return this.config.customTransactionSchema;
|
419
|
+
}
|
420
|
+
set customTransactionSchema(schema) {
|
421
|
+
this._triggerConfigChange('customTransactionSchema', schema);
|
422
|
+
this.config.customTransactionSchema = schema;
|
423
|
+
}
|
424
|
+
_triggerConfigChange(config, newValue) {
|
425
|
+
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
|
426
|
+
name: config,
|
427
|
+
oldValue: this.config[config],
|
428
|
+
newValue,
|
429
|
+
});
|
430
|
+
}
|
431
|
+
}
|
432
|
+
//# 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,OAAO,EAKN,qBAAqB,GAErB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAI9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAwC3D,MAAM,CAAN,IAAY,eAEX;AAFD,WAAY,eAAe;IAC1B,kDAA+B,CAAA;AAChC,CAAC,EAFW,eAAe,KAAf,eAAe,QAE1B;AAED,MAAM,OAAgB,UACrB,SAAQ,gBAAqF;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;Y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