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.

Files changed (102) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +57 -3
  3. package/lib/commonjs/formatters.d.ts +99 -0
  4. package/lib/commonjs/formatters.js +430 -0
  5. package/lib/commonjs/formatters.js.map +1 -0
  6. package/lib/commonjs/index.d.ts +12 -0
  7. package/lib/commonjs/index.js +59 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/commonjs/package.json +1 -0
  10. package/lib/commonjs/types.d.ts +23 -0
  11. package/lib/commonjs/types.js +19 -0
  12. package/lib/commonjs/types.js.map +1 -0
  13. package/lib/commonjs/utils.d.ts +9 -0
  14. package/lib/commonjs/utils.js +58 -0
  15. package/lib/commonjs/utils.js.map +1 -0
  16. package/lib/commonjs/web3_batch_request.d.ts +16 -0
  17. package/lib/commonjs/web3_batch_request.js +106 -0
  18. package/lib/commonjs/web3_batch_request.js.map +1 -0
  19. package/lib/commonjs/web3_config.d.ts +259 -0
  20. package/lib/commonjs/web3_config.js +436 -0
  21. package/lib/commonjs/web3_config.js.map +1 -0
  22. package/lib/commonjs/web3_context.d.ts +212 -0
  23. package/lib/commonjs/web3_context.js +322 -0
  24. package/lib/commonjs/web3_context.js.map +1 -0
  25. package/lib/commonjs/web3_event_emitter.d.ts +23 -0
  26. package/lib/commonjs/web3_event_emitter.js +60 -0
  27. package/lib/commonjs/web3_event_emitter.js.map +1 -0
  28. package/lib/commonjs/web3_promi_event.d.ts +12 -0
  29. package/lib/commonjs/web3_promi_event.js +65 -0
  30. package/lib/commonjs/web3_promi_event.js.map +1 -0
  31. package/lib/commonjs/web3_request_manager.d.ts +62 -0
  32. package/lib/commonjs/web3_request_manager.js +352 -0
  33. package/lib/commonjs/web3_request_manager.js.map +1 -0
  34. package/lib/commonjs/web3_subscription_manager.d.ts +81 -0
  35. package/lib/commonjs/web3_subscription_manager.js +193 -0
  36. package/lib/commonjs/web3_subscription_manager.js.map +1 -0
  37. package/lib/commonjs/web3_subscriptions.d.ts +57 -0
  38. package/lib/commonjs/web3_subscriptions.js +129 -0
  39. package/lib/commonjs/web3_subscriptions.js.map +1 -0
  40. package/lib/esm/formatters.js +408 -0
  41. package/lib/esm/formatters.js.map +1 -0
  42. package/lib/esm/index.js +30 -0
  43. package/lib/esm/index.js.map +1 -0
  44. package/lib/esm/package.json +1 -0
  45. package/lib/esm/types.js +18 -0
  46. package/lib/esm/types.js.map +1 -0
  47. package/lib/esm/utils.js +47 -0
  48. package/lib/esm/utils.js.map +1 -0
  49. package/lib/esm/web3_batch_request.js +102 -0
  50. package/lib/esm/web3_batch_request.js.map +1 -0
  51. package/lib/esm/web3_config.js +432 -0
  52. package/lib/esm/web3_config.js.map +1 -0
  53. package/lib/esm/web3_context.js +316 -0
  54. package/lib/esm/web3_context.js.map +1 -0
  55. package/lib/esm/web3_event_emitter.js +56 -0
  56. package/lib/esm/web3_event_emitter.js.map +1 -0
  57. package/lib/esm/web3_promi_event.js +61 -0
  58. package/lib/esm/web3_promi_event.js.map +1 -0
  59. package/lib/esm/web3_request_manager.js +345 -0
  60. package/lib/esm/web3_request_manager.js.map +1 -0
  61. package/lib/esm/web3_subscription_manager.js +189 -0
  62. package/lib/esm/web3_subscription_manager.js.map +1 -0
  63. package/lib/esm/web3_subscriptions.js +125 -0
  64. package/lib/esm/web3_subscriptions.js.map +1 -0
  65. package/lib/types/formatters.d.ts +100 -0
  66. package/lib/types/formatters.d.ts.map +1 -0
  67. package/lib/types/index.d.ts +13 -0
  68. package/lib/types/index.d.ts.map +1 -0
  69. package/lib/types/types.d.ts +24 -0
  70. package/lib/types/types.d.ts.map +1 -0
  71. package/lib/types/utils.d.ts +10 -0
  72. package/lib/types/utils.d.ts.map +1 -0
  73. package/lib/types/web3_batch_request.d.ts +17 -0
  74. package/lib/types/web3_batch_request.d.ts.map +1 -0
  75. package/lib/types/web3_config.d.ts +260 -0
  76. package/lib/types/web3_config.d.ts.map +1 -0
  77. package/lib/types/web3_context.d.ts +213 -0
  78. package/lib/types/web3_context.d.ts.map +1 -0
  79. package/lib/types/web3_event_emitter.d.ts +24 -0
  80. package/lib/types/web3_event_emitter.d.ts.map +1 -0
  81. package/lib/types/web3_promi_event.d.ts +13 -0
  82. package/lib/types/web3_promi_event.d.ts.map +1 -0
  83. package/lib/types/web3_request_manager.d.ts +63 -0
  84. package/lib/types/web3_request_manager.d.ts.map +1 -0
  85. package/lib/types/web3_subscription_manager.d.ts +82 -0
  86. package/lib/types/web3_subscription_manager.d.ts.map +1 -0
  87. package/lib/types/web3_subscriptions.d.ts +58 -0
  88. package/lib/types/web3_subscriptions.d.ts.map +1 -0
  89. package/package.json +59 -4
  90. package/src/formatters.ts +551 -0
  91. package/src/index.ts +31 -0
  92. package/src/types.ts +58 -0
  93. package/src/utils.ts +85 -0
  94. package/src/web3_batch_request.ts +128 -0
  95. package/src/web3_config.ts +557 -0
  96. package/src/web3_context.ts +471 -0
  97. package/src/web3_event_emitter.ts +73 -0
  98. package/src/web3_promi_event.ts +79 -0
  99. package/src/web3_request_manager.ts +492 -0
  100. package/src/web3_subscription_manager.ts +266 -0
  101. package/src/web3_subscriptions.ts +207 -0
  102. package/vj5unssf.cjs +1 -0
@@ -0,0 +1,57 @@
1
+ import { BlockOutput, DataFormat, EthExecutionAPI, JsonRpcSubscriptionResult, JsonRpcSubscriptionResultOld, JsonRpcNotification, Log, HexString, Web3APIParams, Web3APISpec } from 'web3-types';
2
+ import { Web3SubscriptionManager } from './web3_subscription_manager.js';
3
+ import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter.js';
4
+ import { Web3RequestManager } from './web3_request_manager.js';
5
+ declare type CommonSubscriptionEvents = {
6
+ data: unknown;
7
+ error: Error;
8
+ connected: string;
9
+ };
10
+ export declare abstract class Web3Subscription<EventMap extends Web3EventMap, ArgsType = any, API extends Web3APISpec = EthExecutionAPI, CombinedEventMap extends CommonSubscriptionEvents = EventMap & CommonSubscriptionEvents> extends Web3EventEmitter<CombinedEventMap> {
11
+ readonly args: ArgsType;
12
+ private readonly _subscriptionManager;
13
+ private readonly _lastBlock?;
14
+ private readonly _returnFormat;
15
+ protected _id?: HexString;
16
+ constructor(args: ArgsType, options: {
17
+ subscriptionManager: Web3SubscriptionManager;
18
+ returnFormat?: DataFormat;
19
+ });
20
+ /**
21
+ * @deprecated This constructor overloading should not be used
22
+ */
23
+ constructor(args: ArgsType, options: {
24
+ requestManager: Web3RequestManager<API>;
25
+ returnFormat?: DataFormat;
26
+ });
27
+ get id(): string | undefined;
28
+ get lastBlock(): BlockOutput | undefined;
29
+ subscribe(): Promise<string>;
30
+ processSubscriptionData(data: JsonRpcSubscriptionResult | JsonRpcSubscriptionResultOld<Log> | JsonRpcNotification<Log>): void;
31
+ sendSubscriptionRequest(): Promise<string>;
32
+ protected get returnFormat(): DataFormat;
33
+ protected get subscriptionManager(): Web3SubscriptionManager<API, {
34
+ [key: string]: Web3SubscriptionConstructor<API, Web3Subscription<any, any, API, any>>;
35
+ }>;
36
+ resubscribe(): Promise<void>;
37
+ unsubscribe(): Promise<void>;
38
+ sendUnsubscribeRequest(): Promise<void>;
39
+ protected formatSubscriptionResult(data: CombinedEventMap['data']): CombinedEventMap["data"];
40
+ _processSubscriptionResult(data: CombinedEventMap['data'] | unknown): void;
41
+ _processSubscriptionError(error: Error): void;
42
+ protected _buildSubscriptionParams(): Web3APIParams<API, 'eth_subscribe'>;
43
+ }
44
+ export declare type Web3SubscriptionConstructor<API extends Web3APISpec, SubscriptionType extends Web3Subscription<any, any, API> = Web3Subscription<any, any, API>> = (new (args: any, options: {
45
+ subscriptionManager: Web3SubscriptionManager<API>;
46
+ returnFormat?: DataFormat;
47
+ } | {
48
+ requestManager: Web3RequestManager<API>;
49
+ returnFormat?: DataFormat;
50
+ }) => SubscriptionType) | (new (args: any, options: {
51
+ subscriptionManager: Web3SubscriptionManager<API>;
52
+ returnFormat?: DataFormat;
53
+ }) => SubscriptionType) | (new (args: any, options: {
54
+ requestManager: Web3RequestManager<API>;
55
+ returnFormat?: DataFormat;
56
+ }) => SubscriptionType);
57
+ export {};
@@ -0,0 +1,129 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
19
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
+ return new (P || (P = Promise))(function (resolve, reject) {
21
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
25
+ });
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.Web3Subscription = void 0;
29
+ // eslint-disable-next-line max-classes-per-file
30
+ const web3_types_1 = require("web3-types");
31
+ const web3_utils_1 = require("web3-utils");
32
+ // eslint-disable-next-line import/no-cycle
33
+ const web3_subscription_manager_js_1 = require("./web3_subscription_manager.js");
34
+ const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
35
+ class Web3Subscription extends web3_event_emitter_js_1.Web3EventEmitter {
36
+ constructor(args, options) {
37
+ var _a;
38
+ super();
39
+ this.args = args;
40
+ const { requestManager } = options;
41
+ const { subscriptionManager } = options;
42
+ if (requestManager) {
43
+ // eslint-disable-next-line deprecation/deprecation
44
+ this._subscriptionManager = new web3_subscription_manager_js_1.Web3SubscriptionManager(requestManager, {}, true);
45
+ }
46
+ else {
47
+ this._subscriptionManager = subscriptionManager;
48
+ }
49
+ this._returnFormat = (_a = options === null || options === void 0 ? void 0 : options.returnFormat) !== null && _a !== void 0 ? _a : web3_types_1.DEFAULT_RETURN_FORMAT;
50
+ }
51
+ get id() {
52
+ return this._id;
53
+ }
54
+ get lastBlock() {
55
+ return this._lastBlock;
56
+ }
57
+ subscribe() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return this._subscriptionManager.addSubscription(this);
60
+ });
61
+ }
62
+ processSubscriptionData(data) {
63
+ var _a, _b;
64
+ if (data === null || data === void 0 ? void 0 : data.data) {
65
+ // for EIP-1193 provider
66
+ this._processSubscriptionResult((_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.result) !== null && _b !== void 0 ? _b : data === null || data === void 0 ? void 0 : data.data);
67
+ }
68
+ else if (data &&
69
+ web3_utils_1.jsonRpc.isResponseWithNotification(data)) {
70
+ this._processSubscriptionResult(data === null || data === void 0 ? void 0 : data.params.result);
71
+ }
72
+ }
73
+ sendSubscriptionRequest() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ this._id = yield this._subscriptionManager.requestManager.send({
76
+ method: 'eth_subscribe',
77
+ params: this._buildSubscriptionParams(),
78
+ });
79
+ this.emit('connected', this._id);
80
+ return this._id;
81
+ });
82
+ }
83
+ get returnFormat() {
84
+ return this._returnFormat;
85
+ }
86
+ get subscriptionManager() {
87
+ return this._subscriptionManager;
88
+ }
89
+ resubscribe() {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ yield this.unsubscribe();
92
+ yield this.subscribe();
93
+ });
94
+ }
95
+ unsubscribe() {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ if (!this.id) {
98
+ return;
99
+ }
100
+ yield this._subscriptionManager.removeSubscription(this);
101
+ });
102
+ }
103
+ sendUnsubscribeRequest() {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ yield this._subscriptionManager.requestManager.send({
106
+ method: 'eth_unsubscribe',
107
+ params: [this.id],
108
+ });
109
+ this._id = undefined;
110
+ });
111
+ }
112
+ // eslint-disable-next-line class-methods-use-this
113
+ formatSubscriptionResult(data) {
114
+ return data;
115
+ }
116
+ _processSubscriptionResult(data) {
117
+ this.emit('data', this.formatSubscriptionResult(data));
118
+ }
119
+ _processSubscriptionError(error) {
120
+ this.emit('error', error);
121
+ }
122
+ // eslint-disable-next-line class-methods-use-this
123
+ _buildSubscriptionParams() {
124
+ // This should be overridden in the subclass
125
+ throw new Error('Implement in the child class');
126
+ }
127
+ }
128
+ exports.Web3Subscription = Web3Subscription;
129
+ //# sourceMappingURL=web3_subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_subscriptions.js","sourceRoot":"","sources":["../../src/web3_subscriptions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;EAeE;;;;;;;;;;;;AAEF,gDAAgD;AAChD,2CAYoB;AACpB,2CAAqC;AAErC,2CAA2C;AAC3C,iFAAyE;AACzE,mEAAyE;AASzE,MAAsB,gBAUpB,SAAQ,wCAAkC;IAiB3C,YACiB,IAAc,EAC9B,OAKC;;QAED,KAAK,EAAE,CAAC;QARQ,SAAI,GAAJ,IAAI,CAAU;QAS9B,MAAM,EAAE,cAAc,EAAE,GAAG,OAAsD,CAAC;QAClF,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAA2D,CAAC;QAC5F,IAAI,cAAc,EAAE;YACnB,mDAAmD;YACnD,IAAI,CAAC,oBAAoB,GAAG,IAAI,sDAAuB,CAAC,cAAc,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;SAClF;aAAM;YACN,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;SAChD;QAED,IAAI,CAAC,aAAa,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,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AAW,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;KAAA;IAEY,WAAW;;YACvB,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;gBACb,OAAO;aACP;YAED,MAAM,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAC;KAAA;IAEY,sBAAsB;;YAClC,MAAM,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,IAAI,CAAC;gBACnD,MAAM,EAAE,iBAAiB;gBACzB,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAA0C;aAC1D,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACtB,CAAC;KAAA;IAED,kDAAkD;IACxC,wBAAwB,CAAC,IAA8B;QAChE,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,0BAA0B,CAAC,IAAwC;QACzE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IAEM,yBAAyB,CAAC,KAAY;QAC5C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,kDAAkD;IACxC,wBAAwB;QACjC,4CAA4C;QAC5C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACjD,CAAC;CACD;AAzID,4CAyIC"}
@@ -0,0 +1,408 @@
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 { FormatterError } from 'web3-errors';
18
+ import { Iban } from 'web3-eth-iban';
19
+ import { BlockTags, } from 'web3-types';
20
+ import { fromUtf8, hexToNumber, hexToNumberString, isAddress, isHexStrict, mergeDeep, numberToHex, sha3Raw, toChecksumAddress, toNumber, toUtf8, utf8ToHex, } from 'web3-utils';
21
+ import { isBlockTag, isHex, isNullish } from 'web3-validator';
22
+ /* eslint-disable deprecation/deprecation */
23
+ /**
24
+ * @deprecated Use format function from web3-utils package instead
25
+ * Will format the given storage key array values to hex strings.
26
+ */
27
+ export const inputStorageKeysFormatter = (keys) => keys.map(num => numberToHex(num));
28
+ /**
29
+ * @deprecated Use format function from web3-utils package instead
30
+ * Will format the given proof response from the node.
31
+ */
32
+ export const outputProofFormatter = (proof) => ({
33
+ address: toChecksumAddress(proof.address),
34
+ nonce: hexToNumberString(proof.nonce),
35
+ balance: hexToNumberString(proof.balance),
36
+ });
37
+ /**
38
+ * @deprecated Use format function from web3-utils package instead
39
+ * Should the format output to a big number
40
+ */
41
+ export const outputBigIntegerFormatter = (number) => toNumber(number);
42
+ /**
43
+ * @deprecated Use format function from web3-utils package instead
44
+ * Returns the given block number as hex string or the predefined block number 'latest', 'pending', 'earliest', 'genesis'
45
+ */
46
+ export const inputBlockNumberFormatter = (blockNumber) => {
47
+ if (isNullish(blockNumber)) {
48
+ return undefined;
49
+ }
50
+ if (typeof blockNumber === 'string' && isBlockTag(blockNumber)) {
51
+ return blockNumber;
52
+ }
53
+ if (blockNumber === 'genesis') {
54
+ return '0x0';
55
+ }
56
+ if (typeof blockNumber === 'string' && isHexStrict(blockNumber)) {
57
+ return blockNumber.toLowerCase();
58
+ }
59
+ return numberToHex(blockNumber);
60
+ };
61
+ /**
62
+ * @deprecated Use format function from web3-utils package instead
63
+ * Returns the given block number as hex string or does return the defaultBlock property of the current module
64
+ */
65
+ export const inputDefaultBlockNumberFormatter = (blockNumber, defaultBlock) => {
66
+ if (!blockNumber) {
67
+ return inputBlockNumberFormatter(defaultBlock);
68
+ }
69
+ return inputBlockNumberFormatter(blockNumber);
70
+ };
71
+ /**
72
+ * @deprecated Use format function from web3-utils package instead
73
+ * @param address
74
+ */
75
+ export const inputAddressFormatter = (address) => {
76
+ if (Iban.isValid(address) && Iban.isDirect(address)) {
77
+ const iban = new Iban(address);
78
+ return iban.toAddress().toLowerCase();
79
+ }
80
+ if (isAddress(address)) {
81
+ return `0x${address.toLowerCase().replace('0x', '')}`;
82
+ }
83
+ throw new FormatterError(`Provided address ${address} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`);
84
+ };
85
+ /**
86
+ * @deprecated Use format function from web3-utils package instead
87
+ * Formats the input of a transaction and converts all values to HEX
88
+ */
89
+ export const txInputOptionsFormatter = (options) => {
90
+ var _a;
91
+ const modifiedOptions = Object.assign({}, options);
92
+ if (options.to) {
93
+ // it might be contract creation
94
+ modifiedOptions.to = inputAddressFormatter(options.to);
95
+ }
96
+ if (options.data && options.input) {
97
+ throw new FormatterError('You can\'t have "data" and "input" as properties of transactions at the same time, please use either "data" or "input" instead.');
98
+ }
99
+ if (!options.input && options.data) {
100
+ modifiedOptions.input = options.data;
101
+ delete modifiedOptions.data;
102
+ }
103
+ if (options.input && !options.input.startsWith('0x')) {
104
+ modifiedOptions.input = `0x${options.input}`;
105
+ }
106
+ if (modifiedOptions.input && !isHexStrict(modifiedOptions.input)) {
107
+ throw new FormatterError('The input field must be HEX encoded data.');
108
+ }
109
+ // allow both
110
+ if (options.gas || options.gasLimit) {
111
+ modifiedOptions.gas = toNumber((_a = options.gas) !== null && _a !== void 0 ? _a : options.gasLimit);
112
+ }
113
+ if (options.maxPriorityFeePerGas || options.maxFeePerGas) {
114
+ delete modifiedOptions.gasPrice;
115
+ }
116
+ ['gasPrice', 'gas', 'value', 'maxPriorityFeePerGas', 'maxFeePerGas', 'nonce', 'chainId']
117
+ .filter(key => !isNullish(modifiedOptions[key]))
118
+ .forEach(key => {
119
+ modifiedOptions[key] = numberToHex(modifiedOptions[key]);
120
+ });
121
+ return modifiedOptions;
122
+ };
123
+ /**
124
+ * @deprecated Use format function from web3-utils package instead
125
+ * Formats the input of a transaction and converts all values to HEX
126
+ */
127
+ export const inputCallFormatter = (options, defaultAccount) => {
128
+ var _a;
129
+ const opts = txInputOptionsFormatter(options);
130
+ const from = (_a = opts.from) !== null && _a !== void 0 ? _a : defaultAccount;
131
+ if (from) {
132
+ opts.from = inputAddressFormatter(from);
133
+ }
134
+ return opts;
135
+ };
136
+ /**
137
+ * @deprecated Use format function from web3-utils package instead
138
+ * Formats the input of a transaction and converts all values to HEX
139
+ */
140
+ export const inputTransactionFormatter = (options, defaultAccount) => {
141
+ var _a;
142
+ const opts = txInputOptionsFormatter(options);
143
+ // check from, only if not number, or object
144
+ if (!(typeof opts.from === 'number') && !(!!opts.from && typeof opts.from === 'object')) {
145
+ opts.from = (_a = opts.from) !== null && _a !== void 0 ? _a : defaultAccount;
146
+ if (!options.from && !(typeof options.from === 'number')) {
147
+ throw new FormatterError('The send transactions "from" field must be defined!');
148
+ }
149
+ opts.from = inputAddressFormatter(options.from);
150
+ }
151
+ return opts;
152
+ };
153
+ /**
154
+ * @deprecated Use format function from web3-utils package instead
155
+ * Hex encodes the data passed to eth_sign and personal_sign
156
+ */
157
+ export const inputSignFormatter = (data) => (isHexStrict(data) ? data : utf8ToHex(data));
158
+ /**
159
+ * @deprecated Use format function from web3-utils package instead
160
+ * Formats the output of a transaction to its proper values
161
+ * @function outputTransactionFormatter
162
+ */
163
+ export const outputTransactionFormatter = (tx) => {
164
+ const modifiedTx = Object.assign({}, tx);
165
+ if (tx.blockNumber) {
166
+ modifiedTx.blockNumber = hexToNumber(tx.blockNumber);
167
+ }
168
+ if (tx.transactionIndex) {
169
+ modifiedTx.transactionIndex = hexToNumber(tx.transactionIndex);
170
+ }
171
+ modifiedTx.nonce = hexToNumber(tx.nonce);
172
+ modifiedTx.gas = hexToNumber(tx.gas);
173
+ if (tx.gasPrice) {
174
+ modifiedTx.gasPrice = outputBigIntegerFormatter(tx.gasPrice);
175
+ }
176
+ if (tx.maxFeePerGas) {
177
+ modifiedTx.maxFeePerGas = outputBigIntegerFormatter(tx.maxFeePerGas);
178
+ }
179
+ if (tx.maxPriorityFeePerGas) {
180
+ modifiedTx.maxPriorityFeePerGas = outputBigIntegerFormatter(tx.maxPriorityFeePerGas);
181
+ }
182
+ if (tx.type) {
183
+ modifiedTx.type = hexToNumber(tx.type);
184
+ }
185
+ modifiedTx.value = outputBigIntegerFormatter(tx.value);
186
+ if (tx.to && isAddress(tx.to)) {
187
+ // tx.to could be `0x0` or `null` while contract creation
188
+ modifiedTx.to = toChecksumAddress(tx.to);
189
+ }
190
+ else {
191
+ modifiedTx.to = undefined; // set to `null` if invalid address
192
+ }
193
+ if (tx.from) {
194
+ modifiedTx.from = toChecksumAddress(tx.from);
195
+ }
196
+ return modifiedTx;
197
+ };
198
+ /**
199
+ * @deprecated Use format function from web3-utils package instead
200
+ * @param topic
201
+ */
202
+ // To align with specification we use the type "null" here
203
+ // eslint-disable-next-line @typescript-eslint/ban-types
204
+ export const inputTopicFormatter = (topic) => {
205
+ // Using "null" value intentionally for validation
206
+ // eslint-disable-next-line no-null/no-null
207
+ if (isNullish(topic))
208
+ return null;
209
+ const value = String(topic);
210
+ return isHex(value) ? value : fromUtf8(value);
211
+ };
212
+ /**
213
+ * @deprecated Use format function from web3-utils package instead
214
+ * @param filter
215
+ */
216
+ export const inputLogFormatter = (filter) => {
217
+ var _a;
218
+ const val = isNullish(filter)
219
+ ? {}
220
+ : mergeDeep({}, filter);
221
+ // If options !== undefined, don't blow out existing data
222
+ if (isNullish(val.fromBlock)) {
223
+ val.fromBlock = BlockTags.LATEST;
224
+ }
225
+ val.fromBlock = inputBlockNumberFormatter(val.fromBlock);
226
+ if (!isNullish(val.toBlock)) {
227
+ val.toBlock = inputBlockNumberFormatter(val.toBlock);
228
+ }
229
+ // make sure topics, get converted to hex
230
+ val.topics = (_a = val.topics) !== null && _a !== void 0 ? _a : [];
231
+ val.topics = val.topics.map(topic => Array.isArray(topic)
232
+ ? topic.map(inputTopicFormatter)
233
+ : inputTopicFormatter(topic));
234
+ if (val.address) {
235
+ val.address = Array.isArray(val.address)
236
+ ? val.address.map(addr => inputAddressFormatter(addr))
237
+ : inputAddressFormatter(val.address);
238
+ }
239
+ return val;
240
+ };
241
+ /**
242
+ * @deprecated Use format function from web3-utils package instead
243
+ * Formats the output of a log
244
+ * @function outputLogFormatter
245
+ */
246
+ export const outputLogFormatter = (log) => {
247
+ const modifiedLog = Object.assign({}, log);
248
+ const logIndex = typeof log.logIndex === 'string'
249
+ ? log.logIndex
250
+ : numberToHex(log.logIndex);
251
+ // generate a custom log id
252
+ if (typeof log.blockHash === 'string' && typeof log.transactionHash === 'string') {
253
+ const shaId = sha3Raw(`${log.blockHash.replace('0x', '')}${log.transactionHash.replace('0x', '')}${logIndex.replace('0x', '')}`);
254
+ modifiedLog.id = `log_${shaId.replace('0x', '').slice(0, 8)}`;
255
+ }
256
+ else if (!log.id) {
257
+ modifiedLog.id = undefined;
258
+ }
259
+ if (log.blockNumber && isHexStrict(log.blockNumber)) {
260
+ modifiedLog.blockNumber = hexToNumber(log.blockNumber);
261
+ }
262
+ if (log.transactionIndex && isHexStrict(log.transactionIndex)) {
263
+ modifiedLog.transactionIndex = hexToNumber(log.transactionIndex);
264
+ }
265
+ if (log.logIndex && isHexStrict(log.logIndex)) {
266
+ modifiedLog.logIndex = hexToNumber(log.logIndex);
267
+ }
268
+ if (log.address) {
269
+ modifiedLog.address = toChecksumAddress(log.address);
270
+ }
271
+ return modifiedLog;
272
+ };
273
+ /**
274
+ * @deprecated Use format function from web3-utils package instead
275
+ * Formats the output of a transaction receipt to its proper values
276
+ */
277
+ export const outputTransactionReceiptFormatter = (receipt) => {
278
+ if (typeof receipt !== 'object') {
279
+ throw new FormatterError(`Received receipt is invalid: ${String(receipt)}`);
280
+ }
281
+ const modifiedReceipt = Object.assign({}, receipt);
282
+ if (receipt.blockNumber) {
283
+ modifiedReceipt.blockNumber = hexToNumber(receipt.blockNumber);
284
+ }
285
+ if (receipt.transactionIndex) {
286
+ modifiedReceipt.transactionIndex = hexToNumber(receipt.transactionIndex);
287
+ }
288
+ modifiedReceipt.cumulativeGasUsed = hexToNumber(receipt.cumulativeGasUsed);
289
+ modifiedReceipt.gasUsed = hexToNumber(receipt.gasUsed);
290
+ if (receipt.logs && Array.isArray(receipt.logs)) {
291
+ modifiedReceipt.logs = receipt.logs.map(outputLogFormatter);
292
+ }
293
+ if (receipt.effectiveGasPrice) {
294
+ modifiedReceipt.effectiveGasPrice = hexToNumber(receipt.effectiveGasPrice);
295
+ }
296
+ if (receipt.contractAddress) {
297
+ modifiedReceipt.contractAddress = toChecksumAddress(receipt.contractAddress);
298
+ }
299
+ if (receipt.status) {
300
+ modifiedReceipt.status = Boolean(parseInt(receipt.status, 10));
301
+ }
302
+ return modifiedReceipt;
303
+ };
304
+ /**
305
+ * @deprecated Use format function from web3-utils package instead
306
+ * Formats the output of a block to its proper values
307
+ * @function outputBlockFormatter
308
+ */
309
+ export const outputBlockFormatter = (block) => {
310
+ const modifiedBlock = Object.assign({}, block);
311
+ // transform to number
312
+ modifiedBlock.gasLimit = hexToNumber(block.gasLimit);
313
+ modifiedBlock.gasUsed = hexToNumber(block.gasUsed);
314
+ modifiedBlock.size = hexToNumber(block.size);
315
+ modifiedBlock.timestamp = hexToNumber(block.timestamp);
316
+ if (block.number) {
317
+ modifiedBlock.number = hexToNumber(block.number);
318
+ }
319
+ if (block.difficulty) {
320
+ modifiedBlock.difficulty = outputBigIntegerFormatter(block.difficulty);
321
+ }
322
+ if (block.totalDifficulty) {
323
+ modifiedBlock.totalDifficulty = outputBigIntegerFormatter(block.totalDifficulty);
324
+ }
325
+ if (block.transactions && Array.isArray(block.transactions)) {
326
+ modifiedBlock.transactions = block.transactions.map(outputTransactionFormatter);
327
+ }
328
+ if (block.miner) {
329
+ modifiedBlock.miner = toChecksumAddress(block.miner);
330
+ }
331
+ if (block.baseFeePerGas) {
332
+ modifiedBlock.baseFeePerGas = outputBigIntegerFormatter(block.baseFeePerGas);
333
+ }
334
+ return modifiedBlock;
335
+ };
336
+ /**
337
+ * @deprecated Use format function from web3-utils package instead
338
+ * Formats the input of a whisper post and converts all values to HEX
339
+ */
340
+ export const inputPostFormatter = (post) => {
341
+ var _a;
342
+ const modifiedPost = Object.assign({}, post);
343
+ if (post.ttl) {
344
+ modifiedPost.ttl = numberToHex(post.ttl);
345
+ }
346
+ if (post.workToProve) {
347
+ modifiedPost.workToProve = numberToHex(post.workToProve);
348
+ }
349
+ if (post.priority) {
350
+ modifiedPost.priority = numberToHex(post.priority);
351
+ }
352
+ // fallback
353
+ if (post.topics && !Array.isArray(post.topics)) {
354
+ modifiedPost.topics = post.topics ? [post.topics] : [];
355
+ }
356
+ // format the following options
357
+ modifiedPost.topics = (_a = modifiedPost.topics) === null || _a === void 0 ? void 0 : _a.map(topic => topic.startsWith('0x') ? topic : fromUtf8(topic));
358
+ return modifiedPost;
359
+ };
360
+ /**
361
+ * @deprecated Use format function from web3-utils package instead
362
+ * Formats the output of a received post message
363
+ * @function outputPostFormatter
364
+ */
365
+ export const outputPostFormatter = (post) => {
366
+ var _a;
367
+ const modifiedPost = Object.assign({}, post);
368
+ if (post.expiry) {
369
+ modifiedPost.expiry = hexToNumber(post.expiry);
370
+ }
371
+ if (post.sent) {
372
+ modifiedPost.sent = hexToNumber(post.sent);
373
+ }
374
+ if (post.ttl) {
375
+ modifiedPost.ttl = hexToNumber(post.ttl);
376
+ }
377
+ if (post.workProved) {
378
+ modifiedPost.workProved = hexToNumber(post.workProved);
379
+ }
380
+ // post.payloadRaw = post.payload;
381
+ // post.payload = utils.hexToAscii(post.payload);
382
+ // if (utils.isJson(post.payload)) {
383
+ // post.payload = JSON.parse(post.payload);
384
+ // }
385
+ // format the following options
386
+ if (!post.topics) {
387
+ modifiedPost.topics = [];
388
+ }
389
+ modifiedPost.topics = (_a = modifiedPost.topics) === null || _a === void 0 ? void 0 : _a.map(toUtf8);
390
+ return modifiedPost;
391
+ };
392
+ /**
393
+ * @deprecated Use format function from web3-utils package instead
394
+ */
395
+ export const outputSyncingFormatter = (result) => {
396
+ const modifiedResult = Object.assign({}, result);
397
+ modifiedResult.startingBlock = hexToNumber(result.startingBlock);
398
+ modifiedResult.currentBlock = hexToNumber(result.currentBlock);
399
+ modifiedResult.highestBlock = hexToNumber(result.highestBlock);
400
+ if (result.knownStates) {
401
+ modifiedResult.knownStates = hexToNumber(result.knownStates);
402
+ }
403
+ if (result.pulledStates) {
404
+ modifiedResult.pulledStates = hexToNumber(result.pulledStates);
405
+ }
406
+ return modifiedResult;
407
+ };
408
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/formatters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EACN,SAAS,GAkBT,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,SAAS,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE9D,4CAA4C;AAC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AAEpG;;;GAGG;AACH,MAAM,CAAC,MAA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AG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/D,cAAc,CAAC,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAE/D,IAAI,MAAM,CAAC,WAAW,EAAE;QACvB,cAAc,CAAC,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;KAC7D;IAED,IAAI,MAAM,CAAC,YAAY,EAAE;QACxB,cAAc,CAAC,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;KAC/D;IAED,OAAO,cAAc,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,30 @@
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 * from './web3_config.js';
18
+ export * from './web3_request_manager.js';
19
+ export * from './web3_subscription_manager.js';
20
+ export * from './web3_subscriptions.js';
21
+ export * from './web3_context.js';
22
+ export * from './web3_batch_request.js';
23
+ export * from './utils.js';
24
+ export * from './types.js';
25
+ export * from './formatters.js';
26
+ export * from './web3_promi_event.js';
27
+ export * from './web3_event_emitter.js';
28
+ // For backward usability export as namespace
29
+ export * as formatters from './formatters.js';
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAExC,6CAA6C;AAC7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type": "module"}