Socket
Socket
Sign inDemoInstall

web3-core

Package Overview
Dependencies
0
Maintainers
4
Versions
380
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.3-dev.5afcb54.0 to 4.3.3-dev.5fd9dbb.0

10

lib/commonjs/types.d.ts

@@ -1,2 +0,2 @@

import { HexString, Transaction } from 'web3-types';
import { HexString, JsonRpcResponse, Transaction, Web3APIMethod, Web3APIRequest, Web3APIReturnType } from 'web3-types';
export declare type TransactionTypeParser = (transaction: Transaction) => HexString | undefined;

@@ -11,1 +11,9 @@ export interface Method {

}
export interface RequestManagerMiddleware<API> {
processRequest<AnotherMethod extends Web3APIMethod<API>>(request: Web3APIRequest<API, AnotherMethod>, options?: {
[key: string]: unknown;
}): Promise<Web3APIRequest<API, AnotherMethod>>;
processResponse<AnotherMethod extends Web3APIMethod<API>, ResponseType = Web3APIReturnType<API, AnotherMethod>>(response: JsonRpcResponse<ResponseType>, options?: {
[key: string]: unknown;
}): Promise<JsonRpcResponse<ResponseType>>;
}

5

lib/commonjs/web3_config.d.ts

@@ -1,2 +0,2 @@

import { Numbers, HexString, BlockNumberOrTag, Common } from 'web3-types';
import { Numbers, HexString, BlockNumberOrTag, Common, DataFormat } from 'web3-types';
import { TransactionTypeParser } from './types.js';

@@ -31,2 +31,3 @@ import { TransactionBuilder } from './web3_context.js';

transactionTypeParser?: TransactionTypeParser;
defaultReturnFormat: DataFormat;
}

@@ -189,2 +190,4 @@ declare type ConfigEvent<T, P extends keyof T = keyof T> = P extends unknown ? {

set maxListenersWarningThreshold(val: number);
get defaultReturnFormat(): DataFormat;
set defaultReturnFormat(val: DataFormat);
get defaultNetworkId(): Numbers | undefined;

@@ -191,0 +194,0 @@ set defaultNetworkId(val: Numbers | undefined);

@@ -20,2 +20,3 @@ "use strict";

exports.Web3Config = exports.Web3ConfigEvent = void 0;
const web3_types_1 = require("web3-types");
const web3_errors_1 = require("web3-errors");

@@ -58,2 +59,3 @@ const web3_utils_1 = require("web3-utils");

transactionTypeParser: undefined,
defaultReturnFormat: web3_types_1.DEFAULT_RETURN_FORMAT,
};

@@ -279,2 +281,9 @@ this.setConfig(options !== null && options !== void 0 ? options : {});

}
get defaultReturnFormat() {
return this.config.defaultReturnFormat;
}
set defaultReturnFormat(val) {
this._triggerConfigChange('defaultReturnFormat', val);
this.config.defaultReturnFormat = val;
}
get defaultNetworkId() {

@@ -281,0 +290,0 @@ return this.config.defaultNetworkId;

import { EthExecutionAPI, HexString, Numbers, SupportedProviders, Transaction, Web3AccountProvider, Web3APISpec, Web3BaseProvider, Web3BaseWallet, Web3BaseWalletAccount } from 'web3-types';
import { BaseTransaction } from 'web3-eth-accounts';
import { ExtensionObject } from './types.js';
import { ExtensionObject, RequestManagerMiddleware } from './types.js';
import { Web3BatchRequest } from './web3_batch_request.js';

@@ -31,2 +31,3 @@ import { Web3Config, Web3ConfigOptions } from './web3_config.js';

wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
requestManagerMiddleware?: RequestManagerMiddleware<API>;
};

@@ -156,2 +157,3 @@ export declare type Web3ContextConstructor<T extends Web3Context, T2 extends unknown[]> = new (...args: [...extras: T2, context: Web3ContextObject]) => T;

setProvider(provider?: SupportedProviders<API> | string): boolean;
setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
/**

@@ -163,3 +165,3 @@ * Will return the {@link Web3BatchRequest} constructor.

* This method allows extending the web3 modules.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing some thing new.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
*/

@@ -190,18 +192,18 @@ extend(extendObj: ExtensionObject): this;

/**
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
export declare abstract class Web3EthPluginBase<API extends Web3APISpec = unknown> extends Web3PluginBase<API & EthExecutionAPI> {

@@ -208,0 +210,0 @@ }

@@ -52,6 +52,6 @@ "use strict";

}
const { config, provider, requestManager, subscriptionManager, registeredSubscriptions, accountProvider, wallet, } = providerOrContext;
const { config, provider, requestManager, subscriptionManager, registeredSubscriptions, accountProvider, wallet, requestManagerMiddleware } = providerOrContext;
this.setConfig(config !== null && config !== void 0 ? config : {});
this._requestManager =
requestManager !== null && requestManager !== void 0 ? requestManager : new web3_request_manager_js_1.Web3RequestManager(provider, (_a = config === null || config === void 0 ? void 0 : config.enableExperimentalFeatures) === null || _a === void 0 ? void 0 : _a.useSubscriptionWhenCheckingBlockTimeout);
requestManager !== null && requestManager !== void 0 ? requestManager : new web3_request_manager_js_1.Web3RequestManager(provider, (_a = config === null || config === void 0 ? void 0 : config.enableExperimentalFeatures) === null || _a === void 0 ? void 0 : _a.useSubscriptionWhenCheckingBlockTimeout, requestManagerMiddleware);
if (subscriptionManager) {

@@ -238,2 +238,5 @@ this._subscriptionManager = subscriptionManager;

}
setRequestManagerMiddleware(requestManagerMiddleware) {
this.requestManager.setMiddleware(requestManagerMiddleware);
}
/**

@@ -247,3 +250,3 @@ * Will return the {@link Web3BatchRequest} constructor.

* This method allows extending the web3 modules.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing some thing new.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
*/

@@ -301,18 +304,18 @@ extend(extendObj) {

/**
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
class Web3EthPluginBase extends Web3PluginBase {

@@ -319,0 +322,0 @@ }

@@ -18,3 +18,3 @@ import { EventEmitter } from 'web3-utils';

listenerCount<K extends Web3EventKey<T>>(eventName: K): number;
listeners<K extends Web3EventKey<T>>(eventName: K): Function[];
listeners<K extends Web3EventKey<T>>(eventName: K): ((...args: any[]) => void)[];
eventNames(): (string | symbol)[];

@@ -21,0 +21,0 @@ removeAllListeners(): EventEmitter;

import { EthExecutionAPI, JsonRpcBatchRequest, JsonRpcBatchResponse, SupportedProviders, Web3APIMethod, Web3APIRequest, Web3APIReturnType, Web3APISpec, Web3BaseProviderConstructor } from 'web3-types';
import { Web3EventEmitter } from './web3_event_emitter.js';
import { RequestManagerMiddleware } from './types.js';
export declare enum Web3RequestManagerEvent {

@@ -12,3 +13,4 @@ PROVIDER_CHANGED = "PROVIDER_CHANGED",

private readonly useRpcCallSpecification?;
constructor(provider?: SupportedProviders<API> | string, useRpcCallSpecification?: boolean);
middleware?: RequestManagerMiddleware<API>;
constructor(provider?: SupportedProviders<API> | string, useRpcCallSpecification?: boolean, requestManagerMiddleware?: RequestManagerMiddleware<API>);
/**

@@ -40,2 +42,3 @@ * Will return all available providers

setProvider(provider?: SupportedProviders<API> | string): boolean;
setMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
/**

@@ -42,0 +45,0 @@ *

@@ -48,3 +48,3 @@ "use strict";

class Web3RequestManager extends web3_event_emitter_js_1.Web3EventEmitter {
constructor(provider, useRpcCallSpecification) {
constructor(provider, useRpcCallSpecification, requestManagerMiddleware) {
super();

@@ -55,2 +55,4 @@ if (!(0, web3_utils_1.isNullish)(provider)) {

this.useRpcCallSpecification = useRpcCallSpecification;
if (!(0, web3_utils_1.isNullish)(requestManagerMiddleware))
this.middleware = requestManagerMiddleware;
}

@@ -111,2 +113,5 @@ /**

}
setMiddleware(requestManagerMiddleware) {
this.middleware = requestManagerMiddleware;
}
/**

@@ -123,3 +128,8 @@ *

return __awaiter(this, void 0, void 0, function* () {
const response = yield this._sendRequest(request);
let requestObj = Object.assign({}, request);
if (!(0, web3_utils_1.isNullish)(this.middleware))
requestObj = yield this.middleware.processRequest(requestObj);
let response = yield this._sendRequest(requestObj);
if (!(0, web3_utils_1.isNullish)(this.middleware))
response = yield this.middleware.processResponse(response);
if (web3_utils_1.jsonRpc.isResponseWithResult(response)) {

@@ -313,3 +323,3 @@ return response.result;

// However, more processing will happen at a higher level to decode the error data,
// according to the Error ABI, if it was available as of EIP-838.
// according to the Error ABI, if it was available as of EIP-838.
if (error === null || error === void 0 ? void 0 : error.message.includes('revert'))

@@ -316,0 +326,0 @@ throw new web3_errors_1.ContractExecutionError(error);

@@ -17,2 +17,3 @@ /*

*/
import { DEFAULT_RETURN_FORMAT, } from 'web3-types';
import { ConfigHardforkMismatchError, ConfigChainMismatchError } from 'web3-errors';

@@ -55,2 +56,3 @@ import { isNullish, toHex } from 'web3-utils';

transactionTypeParser: undefined,
defaultReturnFormat: DEFAULT_RETURN_FORMAT,
};

@@ -276,2 +278,9 @@ this.setConfig(options !== null && options !== void 0 ? options : {});

}
get defaultReturnFormat() {
return this.config.defaultReturnFormat;
}
set defaultReturnFormat(val) {
this._triggerConfigChange('defaultReturnFormat', val);
this.config.defaultReturnFormat = val;
}
get defaultNetworkId() {

@@ -278,0 +287,0 @@ return this.config.defaultNetworkId;

@@ -49,6 +49,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
const { config, provider, requestManager, subscriptionManager, registeredSubscriptions, accountProvider, wallet, } = providerOrContext;
const { config, provider, requestManager, subscriptionManager, registeredSubscriptions, accountProvider, wallet, requestManagerMiddleware } = providerOrContext;
this.setConfig(config !== null && config !== void 0 ? config : {});
this._requestManager =
requestManager !== null && requestManager !== void 0 ? requestManager : new Web3RequestManager(provider, (_a = config === null || config === void 0 ? void 0 : config.enableExperimentalFeatures) === null || _a === void 0 ? void 0 : _a.useSubscriptionWhenCheckingBlockTimeout);
requestManager !== null && requestManager !== void 0 ? requestManager : new Web3RequestManager(provider, (_a = config === null || config === void 0 ? void 0 : config.enableExperimentalFeatures) === null || _a === void 0 ? void 0 : _a.useSubscriptionWhenCheckingBlockTimeout, requestManagerMiddleware);
if (subscriptionManager) {

@@ -235,2 +235,5 @@ this._subscriptionManager = subscriptionManager;

}
setRequestManagerMiddleware(requestManagerMiddleware) {
this.requestManager.setMiddleware(requestManagerMiddleware);
}
/**

@@ -244,3 +247,3 @@ * Will return the {@link Web3BatchRequest} constructor.

* This method allows extending the web3 modules.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing some thing new.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
*/

@@ -296,20 +299,20 @@ extend(extendObj) {

/**
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
export class Web3EthPluginBase extends Web3PluginBase {
}
//# sourceMappingURL=web3_context.js.map

@@ -42,3 +42,3 @@ /*

export class Web3RequestManager extends Web3EventEmitter {
constructor(provider, useRpcCallSpecification) {
constructor(provider, useRpcCallSpecification, requestManagerMiddleware) {
super();

@@ -49,2 +49,4 @@ if (!isNullish(provider)) {

this.useRpcCallSpecification = useRpcCallSpecification;
if (!isNullish(requestManagerMiddleware))
this.middleware = requestManagerMiddleware;
}

@@ -105,2 +107,5 @@ /**

}
setMiddleware(requestManagerMiddleware) {
this.middleware = requestManagerMiddleware;
}
/**

@@ -117,3 +122,8 @@ *

return __awaiter(this, void 0, void 0, function* () {
const response = yield this._sendRequest(request);
let requestObj = Object.assign({}, request);
if (!isNullish(this.middleware))
requestObj = yield this.middleware.processRequest(requestObj);
let response = yield this._sendRequest(requestObj);
if (!isNullish(this.middleware))
response = yield this.middleware.processResponse(response);
if (jsonRpc.isResponseWithResult(response)) {

@@ -307,3 +317,3 @@ return response.result;

// However, more processing will happen at a higher level to decode the error data,
// according to the Error ABI, if it was available as of EIP-838.
// according to the Error ABI, if it was available as of EIP-838.
if (error === null || error === void 0 ? void 0 : error.message.includes('revert'))

@@ -310,0 +320,0 @@ throw new ContractExecutionError(error);

@@ -1,2 +0,2 @@

import { HexString, Transaction } from 'web3-types';
import { HexString, JsonRpcResponse, Transaction, Web3APIMethod, Web3APIRequest, Web3APIReturnType } from 'web3-types';
export declare type TransactionTypeParser = (transaction: Transaction) => HexString | undefined;

@@ -11,2 +11,10 @@ export interface Method {

}
export interface RequestManagerMiddleware<API> {
processRequest<AnotherMethod extends Web3APIMethod<API>>(request: Web3APIRequest<API, AnotherMethod>, options?: {
[key: string]: unknown;
}): Promise<Web3APIRequest<API, AnotherMethod>>;
processResponse<AnotherMethod extends Web3APIMethod<API>, ResponseType = Web3APIReturnType<API, AnotherMethod>>(response: JsonRpcResponse<ResponseType>, options?: {
[key: string]: unknown;
}): Promise<JsonRpcResponse<ResponseType>>;
}
//# sourceMappingURL=types.d.ts.map

@@ -1,2 +0,2 @@

import { Numbers, HexString, BlockNumberOrTag, Common } from 'web3-types';
import { Numbers, HexString, BlockNumberOrTag, Common, DataFormat } from 'web3-types';
import { TransactionTypeParser } from './types.js';

@@ -31,2 +31,3 @@ import { TransactionBuilder } from './web3_context.js';

transactionTypeParser?: TransactionTypeParser;
defaultReturnFormat: DataFormat;
}

@@ -189,2 +190,4 @@ declare type ConfigEvent<T, P extends keyof T = keyof T> = P extends unknown ? {

set maxListenersWarningThreshold(val: number);
get defaultReturnFormat(): DataFormat;
set defaultReturnFormat(val: DataFormat);
get defaultNetworkId(): Numbers | undefined;

@@ -191,0 +194,0 @@ set defaultNetworkId(val: Numbers | undefined);

import { EthExecutionAPI, HexString, Numbers, SupportedProviders, Transaction, Web3AccountProvider, Web3APISpec, Web3BaseProvider, Web3BaseWallet, Web3BaseWalletAccount } from 'web3-types';
import { BaseTransaction } from 'web3-eth-accounts';
import { ExtensionObject } from './types.js';
import { ExtensionObject, RequestManagerMiddleware } from './types.js';
import { Web3BatchRequest } from './web3_batch_request.js';

@@ -31,2 +31,3 @@ import { Web3Config, Web3ConfigOptions } from './web3_config.js';

wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
requestManagerMiddleware?: RequestManagerMiddleware<API>;
};

@@ -156,2 +157,3 @@ export declare type Web3ContextConstructor<T extends Web3Context, T2 extends unknown[]> = new (...args: [...extras: T2, context: Web3ContextObject]) => T;

setProvider(provider?: SupportedProviders<API> | string): boolean;
setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
/**

@@ -163,3 +165,3 @@ * Will return the {@link Web3BatchRequest} constructor.

* This method allows extending the web3 modules.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing some thing new.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
*/

@@ -190,18 +192,18 @@ extend(extendObj: ExtensionObject): this;

/**
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
export declare abstract class Web3EthPluginBase<API extends Web3APISpec = unknown> extends Web3PluginBase<API & EthExecutionAPI> {

@@ -208,0 +210,0 @@ }

@@ -18,3 +18,3 @@ import { EventEmitter } from 'web3-utils';

listenerCount<K extends Web3EventKey<T>>(eventName: K): number;
listeners<K extends Web3EventKey<T>>(eventName: K): Function[];
listeners<K extends Web3EventKey<T>>(eventName: K): ((...args: any[]) => void)[];
eventNames(): (string | symbol)[];

@@ -21,0 +21,0 @@ removeAllListeners(): EventEmitter;

import { EthExecutionAPI, JsonRpcBatchRequest, JsonRpcBatchResponse, SupportedProviders, Web3APIMethod, Web3APIRequest, Web3APIReturnType, Web3APISpec, Web3BaseProviderConstructor } from 'web3-types';
import { Web3EventEmitter } from './web3_event_emitter.js';
import { RequestManagerMiddleware } from './types.js';
export declare enum Web3RequestManagerEvent {

@@ -12,3 +13,4 @@ PROVIDER_CHANGED = "PROVIDER_CHANGED",

private readonly useRpcCallSpecification?;
constructor(provider?: SupportedProviders<API> | string, useRpcCallSpecification?: boolean);
middleware?: RequestManagerMiddleware<API>;
constructor(provider?: SupportedProviders<API> | string, useRpcCallSpecification?: boolean, requestManagerMiddleware?: RequestManagerMiddleware<API>);
/**

@@ -40,2 +42,3 @@ * Will return all available providers

setProvider(provider?: SupportedProviders<API> | string): boolean;
setMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
/**

@@ -42,0 +45,0 @@ *

{
"name": "web3-core",
"version": "4.3.3-dev.5afcb54.0+5afcb54",
"version": "4.3.3-dev.5fd9dbb.0+5fd9dbb",
"description": "Web3 core tools for sub-packages. This is an internal package.",

@@ -45,13 +45,13 @@ "main": "./lib/commonjs/index.js",

"dependencies": {
"web3-errors": "1.1.5-dev.5afcb54.0+5afcb54",
"web3-eth-accounts": "4.1.1-dev.5afcb54.0+5afcb54",
"web3-eth-iban": "4.0.8-dev.5afcb54.0+5afcb54",
"web3-providers-http": "4.1.1-dev.5afcb54.0+5afcb54",
"web3-providers-ws": "4.0.8-dev.5afcb54.0+5afcb54",
"web3-types": "1.3.2-dev.5afcb54.0+5afcb54",
"web3-utils": "4.1.1-dev.5afcb54.0+5afcb54",
"web3-validator": "2.0.4-dev.5afcb54.0+5afcb54"
"web3-errors": "1.1.5-dev.5fd9dbb.0+5fd9dbb",
"web3-eth-accounts": "4.1.3-dev.5fd9dbb.0+5fd9dbb",
"web3-eth-iban": "4.0.8-dev.5fd9dbb.0+5fd9dbb",
"web3-providers-http": "4.1.1-dev.5fd9dbb.0+5fd9dbb",
"web3-providers-ws": "4.0.8-dev.5fd9dbb.0+5fd9dbb",
"web3-types": "1.6.1-dev.5fd9dbb.0+5fd9dbb",
"web3-utils": "4.2.4-dev.5fd9dbb.0+5fd9dbb",
"web3-validator": "2.0.6-dev.5fd9dbb.0+5fd9dbb"
},
"optionalDependencies": {
"web3-providers-ipc": "4.0.8-dev.5afcb54.0+5afcb54"
"web3-providers-ipc": "4.0.8-dev.5fd9dbb.0+5fd9dbb"
},

@@ -67,10 +67,10 @@ "devDependencies": {

"eslint-plugin-import": "^2.26.0",
"jest": "^28.1.3",
"jest": "^29.7.0",
"jest-extended": "^3.0.1",
"jest-when": "^3.5.1",
"prettier": "^2.7.1",
"ts-jest": "^28.0.7",
"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
},
"gitHead": "5afcb5411d35b9c3efb1f323336b7c2661328d28"
"gitHead": "5fd9dbb2eda58b22c1d83033e6c2d2a263b3b9e6"
}

@@ -18,3 +18,3 @@ /*

import { HexString, Transaction } from 'web3-types';
import { HexString, JsonRpcResponse, Transaction, Web3APIMethod, Web3APIRequest, Web3APIReturnType } from 'web3-types';

@@ -34,1 +34,16 @@ export type TransactionTypeParser = (

}
export interface RequestManagerMiddleware<API> {
processRequest<
AnotherMethod extends Web3APIMethod<API>
>(
request: Web3APIRequest<API, AnotherMethod>,
options?: { [key: string]: unknown }): Promise<Web3APIRequest<API, AnotherMethod>>;
processResponse<
AnotherMethod extends Web3APIMethod<API>,
ResponseType = Web3APIReturnType<API, AnotherMethod>>
(
response: JsonRpcResponse<ResponseType>,
options?: { [key: string]: unknown }): Promise<JsonRpcResponse<ResponseType>>;
}

@@ -18,3 +18,10 @@ /*

import { Numbers, HexString, BlockNumberOrTag, Common } from 'web3-types';
import {
Numbers,
HexString,
BlockNumberOrTag,
Common,
DEFAULT_RETURN_FORMAT,
DataFormat,
} from 'web3-types';
import { ConfigHardforkMismatchError, ConfigChainMismatchError } from 'web3-errors';

@@ -56,2 +63,3 @@ import { isNullish, toHex } from 'web3-utils';

transactionTypeParser?: TransactionTypeParser;
defaultReturnFormat: DataFormat;
}

@@ -98,2 +106,3 @@

transactionTypeParser: undefined,
defaultReturnFormat: DEFAULT_RETURN_FORMAT,
};

@@ -354,2 +363,11 @@

public get defaultReturnFormat() {
return this.config.defaultReturnFormat;
}
public set defaultReturnFormat(val) {
this._triggerConfigChange('defaultReturnFormat', val);
this.config.defaultReturnFormat = val;
}
public get defaultNetworkId() {

@@ -356,0 +374,0 @@ return this.config.defaultNetworkId;

@@ -28,3 +28,3 @@ /*

// eslint-disable-next-line import/no-cycle
import { ExtensionObject } from './types.js';
import { ExtensionObject, RequestManagerMiddleware } from './types.js';
import { Web3BatchRequest } from './web3_batch_request.js';

@@ -69,2 +69,3 @@ // eslint-disable-next-line import/no-cycle

wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
requestManagerMiddleware?: RequestManagerMiddleware<API>;
};

@@ -108,3 +109,3 @@

super();
// If "providerOrContext" is provided as "string" or an objects matching "SupportedProviders" interface

@@ -135,2 +136,3 @@ if (

wallet,
requestManagerMiddleware
} = providerOrContext as Web3ContextInitOptions<API, RegisteredSubs>;

@@ -145,2 +147,3 @@

config?.enableExperimentalFeatures?.useSubscriptionWhenCheckingBlockTimeout,
requestManagerMiddleware
);

@@ -360,2 +363,7 @@

}
public setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>){
this.requestManager.setMiddleware(requestManagerMiddleware);
}
/**

@@ -373,3 +381,3 @@ * Will return the {@link Web3BatchRequest} constructor.

* This method allows extending the web3 modules.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing some thing new.
* Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
*/

@@ -417,32 +425,35 @@ public extend(extendObj: ExtensionObject) {

*/
export abstract class Web3PluginBase<
API extends Web3APISpec = Web3APISpec,
export abstract class Web3PluginBase<
API extends Web3APISpec = Web3APISpec,
> extends Web3Context<API> {
public abstract pluginNamespace: string;
public abstract pluginNamespace: string;
// eslint-disable-next-line class-methods-use-this
protected registerNewTransactionType<NewTxTypeClass extends typeof BaseTransaction<unknown>>(type: Numbers, txClass: NewTxTypeClass): void {
TransactionFactory.registerTransactionType(type, txClass);
}
// eslint-disable-next-line class-methods-use-this
protected registerNewTransactionType<NewTxTypeClass extends typeof BaseTransaction<unknown>>(
type: Numbers,
txClass: NewTxTypeClass,
): void {
TransactionFactory.registerTransactionType(type, txClass);
}
}
/**
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
* Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
* or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
*
* To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
* define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
*
* @example
* ```ts
* type CustomRpcApi = {
* custom_rpc_method: () => string;
* custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
* };
*
* class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
* ```
*/
export abstract class Web3EthPluginBase<API extends Web3APISpec = unknown> extends Web3PluginBase<
API & EthExecutionAPI
API & EthExecutionAPI
> {}

@@ -449,0 +460,0 @@

@@ -55,2 +55,3 @@ /*

import { Web3EventEmitter } from './web3_event_emitter.js';
import { RequestManagerMiddleware } from './types.js';

@@ -77,5 +78,8 @@ export enum Web3RequestManagerEvent {

private readonly useRpcCallSpecification?: boolean;
public middleware?: RequestManagerMiddleware<API>;
public constructor(
provider?: SupportedProviders<API> | string,
useRpcCallSpecification?: boolean,
requestManagerMiddleware?: RequestManagerMiddleware<API>
) {

@@ -88,4 +92,8 @@ super();

this.useRpcCallSpecification = useRpcCallSpecification;
if (!isNullish(requestManagerMiddleware))
this.middleware = requestManagerMiddleware;
}
/**

@@ -148,2 +156,6 @@ * Will return all available providers

public setMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>){
this.middleware = requestManagerMiddleware;
}
/**

@@ -162,3 +174,13 @@ *

>(request: Web3APIRequest<API, Method>): Promise<ResponseType> {
const response = await this._sendRequest<Method, ResponseType>(request);
let requestObj = {...request};
if (!isNullish(this.middleware))
requestObj = await this.middleware.processRequest(requestObj);
let response = await this._sendRequest<Method, ResponseType>(requestObj);
if (!isNullish(this.middleware))
response = await this.middleware.processResponse(response);
if (jsonRpc.isResponseWithResult(response)) {

@@ -433,6 +455,6 @@ return response.result;

}
// This message means that there was an error while executing the code of the smart contract
// However, more processing will happen at a higher level to decode the error data,
// according to the Error ABI, if it was available as of EIP-838.
// according to the Error ABI, if it was available as of EIP-838.
if (error?.message.includes('revert')) throw new ContractExecutionError(error);

@@ -439,0 +461,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc