web3-core
Advanced tools
Comparing version 4.3.3-dev.c5cecaf.0 to 4.3.3-dev.c62ef79.0
@@ -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>>; | ||
} |
@@ -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; | ||
/** | ||
@@ -158,0 +160,0 @@ * Will return the {@link Web3BatchRequest} constructor. |
@@ -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); | ||
} | ||
/** | ||
@@ -240,0 +243,0 @@ * Will return the {@link Web3BatchRequest} constructor. |
@@ -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)) { | ||
@@ -126,0 +136,0 @@ return response.result; |
@@ -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); | ||
} | ||
/** | ||
@@ -237,0 +240,0 @@ * Will return the {@link Web3BatchRequest} constructor. |
@@ -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)) { | ||
@@ -120,0 +130,0 @@ return response.result; |
@@ -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; | ||
/** | ||
@@ -158,0 +160,0 @@ * Will return the {@link Web3BatchRequest} constructor. |
@@ -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.c5cecaf.0+c5cecaf", | ||
"version": "4.3.3-dev.c62ef79.0+c62ef79", | ||
"description": "Web3 core tools for sub-packages. This is an internal package.", | ||
@@ -33,3 +33,3 @@ "main": "./lib/commonjs/index.js", | ||
"build:check": "node -e \"require('./lib')\"", | ||
"lint": "eslint --ext .js,.ts .", | ||
"lint": "eslint --cache --cache-strategy content --ext .ts .", | ||
"lint:fix": "eslint --fix --ext .js,.ts .", | ||
@@ -46,13 +46,13 @@ "format": "prettier --write '**/*'", | ||
"dependencies": { | ||
"web3-errors": "1.1.5-dev.c5cecaf.0+c5cecaf", | ||
"web3-eth-accounts": "4.1.2-dev.c5cecaf.0+c5cecaf", | ||
"web3-eth-iban": "4.0.8-dev.c5cecaf.0+c5cecaf", | ||
"web3-providers-http": "4.1.1-dev.c5cecaf.0+c5cecaf", | ||
"web3-providers-ws": "4.0.8-dev.c5cecaf.0+c5cecaf", | ||
"web3-types": "1.4.1-dev.c5cecaf.0+c5cecaf", | ||
"web3-utils": "4.2.1-dev.c5cecaf.0+c5cecaf", | ||
"web3-validator": "2.0.5-dev.c5cecaf.0+c5cecaf" | ||
"web3-errors": "1.1.5-dev.c62ef79.0+c62ef79", | ||
"web3-eth-accounts": "4.1.3-dev.c62ef79.0+c62ef79", | ||
"web3-eth-iban": "4.0.8-dev.c62ef79.0+c62ef79", | ||
"web3-providers-http": "4.1.1-dev.c62ef79.0+c62ef79", | ||
"web3-providers-ws": "4.0.8-dev.c62ef79.0+c62ef79", | ||
"web3-types": "1.6.1-dev.c62ef79.0+c62ef79", | ||
"web3-utils": "4.2.4-dev.c62ef79.0+c62ef79", | ||
"web3-validator": "2.0.6-dev.c62ef79.0+c62ef79" | ||
}, | ||
"optionalDependencies": { | ||
"web3-providers-ipc": "4.0.8-dev.c5cecaf.0+c5cecaf" | ||
"web3-providers-ipc": "4.0.8-dev.c62ef79.0+c62ef79" | ||
}, | ||
@@ -75,3 +75,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "c5cecaff543dcdc2946b9759c49e1383bcf8e5bf" | ||
"gitHead": "c62ef79b79b9d86bd59dd68e2773842e49eaedca" | ||
} |
@@ -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>; | ||
}; | ||
@@ -134,2 +135,3 @@ | ||
wallet, | ||
requestManagerMiddleware | ||
} = providerOrContext as Web3ContextInitOptions<API, RegisteredSubs>; | ||
@@ -144,2 +146,3 @@ | ||
config?.enableExperimentalFeatures?.useSubscriptionWhenCheckingBlockTimeout, | ||
requestManagerMiddleware | ||
); | ||
@@ -359,2 +362,7 @@ | ||
} | ||
public setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>){ | ||
this.requestManager.setMiddleware(requestManagerMiddleware); | ||
} | ||
/** | ||
@@ -361,0 +369,0 @@ * Will return the {@link Web3BatchRequest} constructor. |
@@ -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)) { | ||
@@ -165,0 +187,0 @@ return response.result; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
479804
8442