Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-core

Package Overview
Dependencies
Maintainers
5
Versions
496
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-core - npm Package Compare versions

Comparing version 4.0.1-rc.1 to 4.0.1-rc.2

2

lib/commonjs/formatters.js

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

*/
const inputStorageKeysFormatter = (keys) => keys.map(web3_utils_1.numberToHex);
const inputStorageKeysFormatter = (keys) => keys.map(num => (0, web3_utils_1.numberToHex)(num));
exports.inputStorageKeysFormatter = inputStorageKeysFormatter;

@@ -33,0 +33,0 @@ /**

@@ -1,12 +0,12 @@

export * from './web3_config';
export * from './web3_request_manager';
export * from './web3_subscription_manager';
export * from './web3_subscriptions';
export * from './web3_context';
export * from './web3_batch_request';
export * from './utils';
export * from './types';
export * from './formatters';
export * from './web3_promi_event';
export * from './web3_event_emitter';
export * as formatters from './formatters';
export * from './web3_config.js';
export * from './web3_request_manager.js';
export * from './web3_subscription_manager.js';
export * from './web3_subscriptions.js';
export * from './web3_context.js';
export * from './web3_batch_request.js';
export * from './utils.js';
export * from './types.js';
export * from './formatters.js';
export * from './web3_promi_event.js';
export * from './web3_event_emitter.js';
export * as formatters from './formatters.js';

@@ -46,15 +46,15 @@ "use strict";

exports.formatters = void 0;
__exportStar(require("./web3_config"), exports);
__exportStar(require("./web3_request_manager"), exports);
__exportStar(require("./web3_subscription_manager"), exports);
__exportStar(require("./web3_subscriptions"), exports);
__exportStar(require("./web3_context"), exports);
__exportStar(require("./web3_batch_request"), exports);
__exportStar(require("./utils"), exports);
__exportStar(require("./types"), exports);
__exportStar(require("./formatters"), exports);
__exportStar(require("./web3_promi_event"), exports);
__exportStar(require("./web3_event_emitter"), exports);
__exportStar(require("./web3_config.js"), exports);
__exportStar(require("./web3_request_manager.js"), exports);
__exportStar(require("./web3_subscription_manager.js"), exports);
__exportStar(require("./web3_subscriptions.js"), exports);
__exportStar(require("./web3_context.js"), exports);
__exportStar(require("./web3_batch_request.js"), exports);
__exportStar(require("./utils.js"), exports);
__exportStar(require("./types.js"), exports);
__exportStar(require("./formatters.js"), exports);
__exportStar(require("./web3_promi_event.js"), exports);
__exportStar(require("./web3_event_emitter.js"), exports);
// For backward usability export as namespace
exports.formatters = __importStar(require("./formatters"));
exports.formatters = __importStar(require("./formatters.js"));
//# sourceMappingURL=index.js.map
import { JsonRpcBatchResponse, JsonRpcOptionalRequest, JsonRpcRequest } from 'web3-types';
import { Web3DeferredPromise } from 'web3-utils';
import { Web3RequestManager } from './web3_request_manager';
import { Web3RequestManager } from './web3_request_manager.js';
export declare const DEFAULT_BATCH_REQUEST_TIMEOUT = 1000;

@@ -5,0 +5,0 @@ export declare class Web3BatchRequest {

import { Numbers, HexString, BlockNumberOrTag, Common } from 'web3-types';
import { TransactionTypeParser } from './types';
import { TransactionBuilder } from './web3_context';
import { Web3EventEmitter } from './web3_event_emitter';
import { TransactionTypeParser } from './types.js';
import { TransactionBuilder } from './web3_context.js';
import { Web3EventEmitter } from './web3_event_emitter.js';
export interface Web3ConfigOptions {

@@ -151,3 +151,3 @@ handleRevert: boolean;

/**
* 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.
* 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.
* Default is `10` seconds.

@@ -154,0 +154,0 @@ */

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

const web3_utils_1 = require("web3-utils");
const web3_event_emitter_1 = require("./web3_event_emitter");
const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
var Web3ConfigEvent;

@@ -28,3 +28,3 @@ (function (Web3ConfigEvent) {

})(Web3ConfigEvent = exports.Web3ConfigEvent || (exports.Web3ConfigEvent = {}));
class Web3Config extends web3_event_emitter_1.Web3EventEmitter {
class Web3Config extends web3_event_emitter_js_1.Web3EventEmitter {
constructor(options) {

@@ -82,7 +82,3 @@ super();

set handleRevert(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'handleRevert',
oldValue: this.config.handleRevert,
newValue: val,
});
this._triggerConfigChange('handleRevert', val);
this.config.handleRevert = val;

@@ -104,7 +100,3 @@ }

set defaultAccount(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultAccount',
oldValue: this.config.defaultAccount,
newValue: val,
});
this._triggerConfigChange('defaultAccount', val);
this.config.defaultAccount = val;

@@ -135,7 +127,3 @@ }

set defaultBlock(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultBlock',
oldValue: this.config.defaultBlock,
newValue: val,
});
this._triggerConfigChange('defaultBlock', val);
this.config.defaultBlock = val;

@@ -155,7 +143,3 @@ }

set transactionSendTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionSendTimeout',
oldValue: this.config.transactionSendTimeout,
newValue: val,
});
this._triggerConfigChange('transactionSendTimeout', val);
this.config.transactionSendTimeout = val;

@@ -174,7 +158,3 @@ }

set transactionBlockTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionBlockTimeout',
oldValue: this.config.transactionBlockTimeout,
newValue: val,
});
this._triggerConfigChange('transactionBlockTimeout', val);
this.config.transactionBlockTimeout = val;

@@ -193,7 +173,3 @@ }

set transactionConfirmationBlocks(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationBlocks',
oldValue: this.config.transactionConfirmationBlocks,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationBlocks', val);
this.config.transactionConfirmationBlocks = val;

@@ -212,7 +188,3 @@ }

set transactionPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionPollingInterval',
oldValue: this.config.transactionPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionPollingInterval', val);
this.config.transactionPollingInterval = val;

@@ -247,7 +219,3 @@ this.transactionReceiptPollingInterval = val;

set transactionReceiptPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionReceiptPollingInterval',
oldValue: this.config.transactionReceiptPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionReceiptPollingInterval', val);
this.config.transactionReceiptPollingInterval = val;

@@ -259,11 +227,7 @@ }

set transactionConfirmationPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationPollingInterval',
oldValue: this.config.transactionConfirmationPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
this.config.transactionConfirmationPollingInterval = val;
}
/**
* 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.
* 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.
* Default is `10` seconds.

@@ -270,0 +234,0 @@ */

@@ -1,8 +0,7 @@

/// <reference types="node" />
import { Web3APISpec, Web3BaseWallet, Web3BaseWalletAccount, Web3AccountProvider, SupportedProviders, HexString, EthExecutionAPI, Web3BaseProvider, Transaction } from 'web3-types';
import { Web3Config, Web3ConfigOptions } from './web3_config';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { Web3SubscriptionManager } from './web3_subscription_manager';
import { Web3BatchRequest } from './web3_batch_request';
import { Web3Config, Web3ConfigOptions } from './web3_config.js';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
import { Web3BatchRequest } from './web3_batch_request.js';
export declare type Web3ContextObject<API extends Web3APISpec = unknown, RegisteredSubs extends {

@@ -162,3 +161,4 @@ [key: string]: Web3SubscriptionConstructor<API>;

web3Context: Web3Context<API>;
privateKey?: HexString | Buffer;
privateKey?: HexString | Uint8Array;
fillGasPrice?: boolean;
}) => Promise<ReturnType>;

@@ -165,0 +165,0 @@ /**

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

const web3_errors_1 = require("web3-errors");
const utils_1 = require("./utils");
const utils_js_1 = require("./utils.js");
// eslint-disable-next-line import/no-cycle
const web3_config_1 = require("./web3_config");
const web3_request_manager_1 = require("./web3_request_manager");
const web3_subscription_manager_1 = require("./web3_subscription_manager");
const web3_batch_request_1 = require("./web3_batch_request");
class Web3Context extends web3_config_1.Web3Config {
const web3_config_js_1 = require("./web3_config.js");
const web3_request_manager_js_1 = require("./web3_request_manager.js");
const web3_subscription_manager_js_1 = require("./web3_subscription_manager.js");
const web3_batch_request_js_1 = require("./web3_batch_request.js");
class Web3Context extends web3_config_js_1.Web3Config {
constructor(providerOrContext) {
var _a;
super();
this.providers = web3_request_manager_1.Web3RequestManager.providers;
this.providers = web3_request_manager_js_1.Web3RequestManager.providers;
// If "providerOrContext" is provided as "string" or an objects matching "SupportedProviders" interface
if ((0, web3_utils_1.isNullish)(providerOrContext) ||
(typeof providerOrContext === 'string' && providerOrContext.trim() !== '') ||
(0, utils_1.isSupportedProvider)(providerOrContext)) {
this._requestManager = new web3_request_manager_1.Web3RequestManager(providerOrContext);
this._subscriptionManager = new web3_subscription_manager_1.Web3SubscriptionManager(this._requestManager, {});
(0, utils_js_1.isSupportedProvider)(providerOrContext)) {
this._requestManager = new web3_request_manager_js_1.Web3RequestManager(providerOrContext);
this._subscriptionManager = new web3_subscription_manager_js_1.Web3SubscriptionManager(this._requestManager, {});
return;

@@ -29,3 +29,3 @@ }

this._requestManager =
requestManager !== null && requestManager !== void 0 ? requestManager : new web3_request_manager_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);
if (subscriptionManager) {

@@ -35,3 +35,3 @@ this._subscriptionManager = subscriptionManager;

else if (registeredSubscriptions) {
this._subscriptionManager = new web3_subscription_manager_1.Web3SubscriptionManager(this.requestManager, registeredSubscriptions);
this._subscriptionManager = new web3_subscription_manager_js_1.Web3SubscriptionManager(this.requestManager, registeredSubscriptions);
}

@@ -84,3 +84,3 @@ if (accountProvider) {

const newContextChild = new ContextRef(...[...args, this.getContextObject()]);
this.on(web3_config_1.Web3ConfigEvent.CONFIG_CHANGE, event => {
this.on(web3_config_js_1.Web3ConfigEvent.CONFIG_CHANGE, event => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

@@ -101,3 +101,3 @@ newContextChild.setConfig({ [event.name]: event.newValue });

this._accountProvider = parentContext._accountProvider;
parentContext.on(web3_config_1.Web3ConfigEvent.CONFIG_CHANGE, event => {
parentContext.on(web3_config_js_1.Web3ConfigEvent.CONFIG_CHANGE, event => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

@@ -218,7 +218,7 @@ this.setConfig({ [event.name]: event.newValue });

get BatchRequest() {
return web3_batch_request_1.Web3BatchRequest.bind(undefined, this._requestManager);
return web3_batch_request_js_1.Web3BatchRequest.bind(undefined, this._requestManager);
}
}
exports.Web3Context = Web3Context;
Web3Context.providers = web3_request_manager_1.Web3RequestManager.providers;
Web3Context.providers = web3_request_manager_js_1.Web3RequestManager.providers;
/**

@@ -225,0 +225,0 @@ * Extend this class when creating a plugin that either doesn't require {@link EthExecutionAPI},

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

import { Web3EventCallback, Web3EventEmitter, Web3EventKey, Web3EventMap } from './web3_event_emitter';
import { Web3EventCallback, Web3EventEmitter, Web3EventKey, Web3EventMap } from './web3_event_emitter.js';
export declare type PromiseExecutor<T> = (resolve: (data: T) => void, reject: (reason: unknown) => void) => void;

@@ -3,0 +3,0 @@ export declare class Web3PromiEvent<ResolveType, EventMap extends Web3EventMap> extends Web3EventEmitter<EventMap> implements Promise<ResolveType> {

@@ -30,4 +30,4 @@ "use strict";

exports.Web3PromiEvent = void 0;
const web3_event_emitter_1 = require("./web3_event_emitter");
class Web3PromiEvent extends web3_event_emitter_1.Web3EventEmitter {
const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
class Web3PromiEvent extends web3_event_emitter_js_1.Web3EventEmitter {
constructor(executor) {

@@ -34,0 +34,0 @@ super();

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

@@ -4,0 +4,0 @@ PROVIDER_CHANGED = "PROVIDER_CHANGED",

@@ -36,4 +36,4 @@ "use strict";

const web3_utils_1 = require("web3-utils");
const utils_1 = require("./utils");
const web3_event_emitter_1 = require("./web3_event_emitter");
const utils_js_1 = require("./utils.js");
const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
var Web3RequestManagerEvent;

@@ -48,3 +48,3 @@ (function (Web3RequestManagerEvent) {

};
class Web3RequestManager extends web3_event_emitter_1.Web3EventEmitter {
class Web3RequestManager extends web3_event_emitter_js_1.Web3EventEmitter {
constructor(provider, useRpcCallSpecification) {

@@ -149,3 +149,3 @@ super();

: web3_utils_1.jsonRpc.toPayload(request);
if ((0, utils_1.isWeb3Provider)(provider)) {
if ((0, utils_js_1.isWeb3Provider)(provider)) {
let response;

@@ -161,3 +161,3 @@ try {

}
if ((0, utils_1.isEIP1193Provider)(provider)) {
if ((0, utils_js_1.isEIP1193Provider)(provider)) {
return provider

@@ -172,3 +172,3 @@ .request(payload)

// TODO: This could be deprecated and removed.
if ((0, utils_1.isLegacyRequestProvider)(provider)) {
if ((0, utils_js_1.isLegacyRequestProvider)(provider)) {
return new Promise((resolve, reject) => {

@@ -205,3 +205,3 @@ const rejectWithError = (err) => reject(this._processJsonRpcResponse(payload, err, {

// TODO: This could be deprecated and removed.
if ((0, utils_1.isLegacySendProvider)(provider)) {
if ((0, utils_js_1.isLegacySendProvider)(provider)) {
return new Promise((resolve, reject) => {

@@ -226,3 +226,3 @@ provider.send(payload, (err, response) => {

// TODO: This could be deprecated and removed.
if ((0, utils_1.isLegacySendAsyncProvider)(provider)) {
if ((0, utils_js_1.isLegacySendAsyncProvider)(provider)) {
return provider

@@ -229,0 +229,0 @@ .sendAsync(payload)

import { DataFormat, Web3APISpec } from 'web3-types';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
declare type ShouldUnsubscribeCondition = ({ id, sub, }: {

@@ -5,0 +5,0 @@ id: string;

@@ -32,4 +32,4 @@ "use strict";

const web3_utils_1 = require("web3-utils");
const utils_1 = require("./utils");
const web3_request_manager_1 = require("./web3_request_manager");
const utils_js_1 = require("./utils.js");
const web3_request_manager_js_1 = require("./web3_request_manager.js");
class Web3SubscriptionManager {

@@ -51,6 +51,6 @@ /**

this._subscriptions = new Map();
this.requestManager.on(web3_request_manager_1.Web3RequestManagerEvent.BEFORE_PROVIDER_CHANGE, () => __awaiter(this, void 0, void 0, function* () {
this.requestManager.on(web3_request_manager_js_1.Web3RequestManagerEvent.BEFORE_PROVIDER_CHANGE, () => __awaiter(this, void 0, void 0, function* () {
yield this.unsubscribe();
}));
this.requestManager.on(web3_request_manager_1.Web3RequestManagerEvent.PROVIDER_CHANGED, () => {
this.requestManager.on(web3_request_manager_js_1.Web3RequestManagerEvent.PROVIDER_CHANGED, () => {
this.clear();

@@ -163,3 +163,3 @@ });

? false
: (0, utils_1.isSupportSubscriptions)(this.requestManager.provider);
: (0, utils_js_1.isSupportSubscriptions)(this.requestManager.provider);
}

@@ -166,0 +166,0 @@ }

import { BlockOutput, Web3APISpec, Web3APIParams, EthExecutionAPI, DataFormat } from 'web3-types';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter';
import { Web3RequestManager } from './web3_request_manager';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter.js';
import { Web3RequestManager } from './web3_request_manager.js';
export declare abstract class Web3Subscription<EventMap extends Web3EventMap, ArgsType = any, API extends Web3APISpec = EthExecutionAPI> extends Web3EventEmitter<EventMap> {

@@ -5,0 +5,0 @@ readonly args: ArgsType;

@@ -32,4 +32,4 @@ "use strict";

const web3_utils_1 = require("web3-utils");
const web3_event_emitter_1 = require("./web3_event_emitter");
class Web3Subscription extends web3_event_emitter_1.Web3EventEmitter {
const web3_event_emitter_js_1 = require("./web3_event_emitter.js");
class Web3Subscription extends web3_event_emitter_js_1.Web3EventEmitter {
constructor(args, options) {

@@ -54,11 +54,20 @@ var _a;

});
const messageListener = (err, data) => {
if (data && web3_utils_1.jsonRpc.isResponseWithNotification(data)) {
const messageListener = (data) => {
var _a, _b;
// for EIP-1193 provider
if (data === null || data === void 0 ? void 0 : data.data) {
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);
return;
}
if (data &&
web3_utils_1.jsonRpc.isResponseWithNotification(data)) {
this._processSubscriptionResult(data === null || data === void 0 ? void 0 : data.params.result);
}
if (err) {
this._processSubscriptionError(err);
}
};
this._requestManager.provider.on('message', messageListener);
if (typeof this._requestManager.provider.request === 'function') {
this._requestManager.provider.on('message', messageListener);
}
else {
this._requestManager.provider.on('data', messageListener);
}
this._messageListener = messageListener;

@@ -65,0 +74,0 @@ });

@@ -27,3 +27,3 @@ /*

*/
export const inputStorageKeysFormatter = (keys) => keys.map(numberToHex);
export const inputStorageKeysFormatter = (keys) => keys.map(num => numberToHex(num));
/**

@@ -30,0 +30,0 @@ * @deprecated Use format function from web3-utils package instead

@@ -17,15 +17,15 @@ /*

*/
export * from './web3_config';
export * from './web3_request_manager';
export * from './web3_subscription_manager';
export * from './web3_subscriptions';
export * from './web3_context';
export * from './web3_batch_request';
export * from './utils';
export * from './types';
export * from './formatters';
export * from './web3_promi_event';
export * from './web3_event_emitter';
export * from './web3_config.js';
export * from './web3_request_manager.js';
export * from './web3_subscription_manager.js';
export * from './web3_subscriptions.js';
export * from './web3_context.js';
export * from './web3_batch_request.js';
export * from './utils.js';
export * from './types.js';
export * from './formatters.js';
export * from './web3_promi_event.js';
export * from './web3_event_emitter.js';
// For backward usability export as namespace
export * as formatters from './formatters';
export * as formatters from './formatters.js';
//# sourceMappingURL=index.js.map

@@ -19,3 +19,3 @@ /*

import { isNullish, toHex } from 'web3-utils';
import { Web3EventEmitter } from './web3_event_emitter';
import { Web3EventEmitter } from './web3_event_emitter.js';
export var Web3ConfigEvent;

@@ -78,7 +78,3 @@ (function (Web3ConfigEvent) {

set handleRevert(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'handleRevert',
oldValue: this.config.handleRevert,
newValue: val,
});
this._triggerConfigChange('handleRevert', val);
this.config.handleRevert = val;

@@ -100,7 +96,3 @@ }

set defaultAccount(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultAccount',
oldValue: this.config.defaultAccount,
newValue: val,
});
this._triggerConfigChange('defaultAccount', val);
this.config.defaultAccount = val;

@@ -131,7 +123,3 @@ }

set defaultBlock(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultBlock',
oldValue: this.config.defaultBlock,
newValue: val,
});
this._triggerConfigChange('defaultBlock', val);
this.config.defaultBlock = val;

@@ -151,7 +139,3 @@ }

set transactionSendTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionSendTimeout',
oldValue: this.config.transactionSendTimeout,
newValue: val,
});
this._triggerConfigChange('transactionSendTimeout', val);
this.config.transactionSendTimeout = val;

@@ -170,7 +154,3 @@ }

set transactionBlockTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionBlockTimeout',
oldValue: this.config.transactionBlockTimeout,
newValue: val,
});
this._triggerConfigChange('transactionBlockTimeout', val);
this.config.transactionBlockTimeout = val;

@@ -189,7 +169,3 @@ }

set transactionConfirmationBlocks(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationBlocks',
oldValue: this.config.transactionConfirmationBlocks,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationBlocks', val);
this.config.transactionConfirmationBlocks = val;

@@ -208,7 +184,3 @@ }

set transactionPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionPollingInterval',
oldValue: this.config.transactionPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionPollingInterval', val);
this.config.transactionPollingInterval = val;

@@ -243,7 +215,3 @@ this.transactionReceiptPollingInterval = val;

set transactionReceiptPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionReceiptPollingInterval',
oldValue: this.config.transactionReceiptPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionReceiptPollingInterval', val);
this.config.transactionReceiptPollingInterval = val;

@@ -255,11 +223,7 @@ }

set transactionConfirmationPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationPollingInterval',
oldValue: this.config.transactionConfirmationPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
this.config.transactionConfirmationPollingInterval = val;
}
/**
* 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.
* 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.
* Default is `10` seconds.

@@ -266,0 +230,0 @@ */

import { isNullish } from 'web3-utils';
import { ExistingPluginNamespaceError } from 'web3-errors';
import { isSupportedProvider } from './utils';
import { isSupportedProvider } from './utils.js';
// eslint-disable-next-line import/no-cycle
import { Web3Config, Web3ConfigEvent } from './web3_config';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionManager } from './web3_subscription_manager';
import { Web3BatchRequest } from './web3_batch_request';
import { Web3Config, Web3ConfigEvent } from './web3_config.js';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
import { Web3BatchRequest } from './web3_batch_request.js';
export class Web3Context extends Web3Config {

@@ -10,0 +10,0 @@ constructor(providerOrContext) {

@@ -27,3 +27,3 @@ /*

var _a;
import { Web3EventEmitter, } from './web3_event_emitter';
import { Web3EventEmitter, } from './web3_event_emitter.js';
export class Web3PromiEvent extends Web3EventEmitter {

@@ -30,0 +30,0 @@ constructor(executor) {

@@ -30,4 +30,4 @@ /*

import { isNullish, isPromise, jsonRpc, isResponseRpcError } from 'web3-utils';
import { isEIP1193Provider, isLegacyRequestProvider, isLegacySendAsyncProvider, isLegacySendProvider, isWeb3Provider, } from './utils';
import { Web3EventEmitter } from './web3_event_emitter';
import { isEIP1193Provider, isLegacyRequestProvider, isLegacySendAsyncProvider, isLegacySendProvider, isWeb3Provider, } from './utils.js';
import { Web3EventEmitter } from './web3_event_emitter.js';
export var Web3RequestManagerEvent;

@@ -34,0 +34,0 @@ (function (Web3RequestManagerEvent) {

@@ -29,4 +29,4 @@ /*

import { isNullish } from 'web3-utils';
import { isSupportSubscriptions } from './utils';
import { Web3RequestManagerEvent } from './web3_request_manager';
import { isSupportSubscriptions } from './utils.js';
import { Web3RequestManagerEvent } from './web3_request_manager.js';
export class Web3SubscriptionManager {

@@ -33,0 +33,0 @@ /**

@@ -29,3 +29,3 @@ /*

import { jsonRpc } from 'web3-utils';
import { Web3EventEmitter } from './web3_event_emitter';
import { Web3EventEmitter } from './web3_event_emitter.js';
export class Web3Subscription extends Web3EventEmitter {

@@ -51,11 +51,20 @@ constructor(args, options) {

});
const messageListener = (err, data) => {
if (data && jsonRpc.isResponseWithNotification(data)) {
const messageListener = (data) => {
var _a, _b;
// for EIP-1193 provider
if (data === null || data === void 0 ? void 0 : data.data) {
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);
return;
}
if (data &&
jsonRpc.isResponseWithNotification(data)) {
this._processSubscriptionResult(data === null || data === void 0 ? void 0 : data.params.result);
}
if (err) {
this._processSubscriptionError(err);
}
};
this._requestManager.provider.on('message', messageListener);
if (typeof this._requestManager.provider.request === 'function') {
this._requestManager.provider.on('message', messageListener);
}
else {
this._requestManager.provider.on('data', messageListener);
}
this._messageListener = messageListener;

@@ -62,0 +71,0 @@ });

@@ -1,13 +0,13 @@

export * from './web3_config';
export * from './web3_request_manager';
export * from './web3_subscription_manager';
export * from './web3_subscriptions';
export * from './web3_context';
export * from './web3_batch_request';
export * from './utils';
export * from './types';
export * from './formatters';
export * from './web3_promi_event';
export * from './web3_event_emitter';
export * as formatters from './formatters';
export * from './web3_config.js';
export * from './web3_request_manager.js';
export * from './web3_subscription_manager.js';
export * from './web3_subscriptions.js';
export * from './web3_context.js';
export * from './web3_batch_request.js';
export * from './utils.js';
export * from './types.js';
export * from './formatters.js';
export * from './web3_promi_event.js';
export * from './web3_event_emitter.js';
export * as formatters from './formatters.js';
//# sourceMappingURL=index.d.ts.map
import { JsonRpcBatchResponse, JsonRpcOptionalRequest, JsonRpcRequest } from 'web3-types';
import { Web3DeferredPromise } from 'web3-utils';
import { Web3RequestManager } from './web3_request_manager';
import { Web3RequestManager } from './web3_request_manager.js';
export declare const DEFAULT_BATCH_REQUEST_TIMEOUT = 1000;

@@ -5,0 +5,0 @@ export declare class Web3BatchRequest {

import { Numbers, HexString, BlockNumberOrTag, Common } from 'web3-types';
import { TransactionTypeParser } from './types';
import { TransactionBuilder } from './web3_context';
import { Web3EventEmitter } from './web3_event_emitter';
import { TransactionTypeParser } from './types.js';
import { TransactionBuilder } from './web3_context.js';
import { Web3EventEmitter } from './web3_event_emitter.js';
export interface Web3ConfigOptions {

@@ -151,3 +151,3 @@ handleRevert: boolean;

/**
* 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.
* 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.
* Default is `10` seconds.

@@ -154,0 +154,0 @@ */

@@ -1,8 +0,7 @@

/// <reference types="node" />
import { Web3APISpec, Web3BaseWallet, Web3BaseWalletAccount, Web3AccountProvider, SupportedProviders, HexString, EthExecutionAPI, Web3BaseProvider, Transaction } from 'web3-types';
import { Web3Config, Web3ConfigOptions } from './web3_config';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { Web3SubscriptionManager } from './web3_subscription_manager';
import { Web3BatchRequest } from './web3_batch_request';
import { Web3Config, Web3ConfigOptions } from './web3_config.js';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
import { Web3BatchRequest } from './web3_batch_request.js';
export declare type Web3ContextObject<API extends Web3APISpec = unknown, RegisteredSubs extends {

@@ -162,3 +161,4 @@ [key: string]: Web3SubscriptionConstructor<API>;

web3Context: Web3Context<API>;
privateKey?: HexString | Buffer;
privateKey?: HexString | Uint8Array;
fillGasPrice?: boolean;
}) => Promise<ReturnType>;

@@ -165,0 +165,0 @@ /**

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

import { Web3EventCallback, Web3EventEmitter, Web3EventKey, Web3EventMap } from './web3_event_emitter';
import { Web3EventCallback, Web3EventEmitter, Web3EventKey, Web3EventMap } from './web3_event_emitter.js';
export declare type PromiseExecutor<T> = (resolve: (data: T) => void, reject: (reason: unknown) => void) => void;

@@ -3,0 +3,0 @@ export declare class Web3PromiEvent<ResolveType, EventMap extends Web3EventMap> extends Web3EventEmitter<EventMap> implements Promise<ResolveType> {

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

@@ -4,0 +4,0 @@ PROVIDER_CHANGED = "PROVIDER_CHANGED",

import { DataFormat, Web3APISpec } from 'web3-types';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
declare type ShouldUnsubscribeCondition = ({ id, sub, }: {

@@ -5,0 +5,0 @@ id: string;

import { BlockOutput, Web3APISpec, Web3APIParams, EthExecutionAPI, DataFormat } from 'web3-types';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter';
import { Web3RequestManager } from './web3_request_manager';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter.js';
import { Web3RequestManager } from './web3_request_manager.js';
export declare abstract class Web3Subscription<EventMap extends Web3EventMap, ArgsType = any, API extends Web3APISpec = EthExecutionAPI> extends Web3EventEmitter<EventMap> {

@@ -5,0 +5,0 @@ readonly args: ArgsType;

{
"name": "web3-core",
"version": "4.0.1-rc.1",
"version": "4.0.1-rc.2",
"description": "Web3 core tools for sub-packages. This is an internal package.",

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

"dependencies": {
"web3-errors": "^1.0.0-rc.1",
"web3-eth-iban": "^4.0.1-rc.1",
"web3-providers-http": "^4.0.1-rc.1",
"web3-providers-ws": "^4.0.1-rc.1",
"web3-types": "^1.0.0-rc.1",
"web3-utils": "^4.0.1-rc.1",
"web3-validator": "^1.0.0-rc.1"
"web3-errors": "^1.0.0-rc.2",
"web3-eth-iban": "^4.0.1-rc.2",
"web3-providers-http": "^4.0.1-rc.2",
"web3-providers-ws": "^4.0.1-rc.2",
"web3-types": "^1.0.0-rc.2",
"web3-utils": "^4.0.1-rc.2",
"web3-validator": "^1.0.0-rc.2"
},
"optionalDependencies": {
"web3-providers-ipc": "^4.0.1-rc.1"
"web3-providers-ipc": "^4.0.1-rc.2"
},

@@ -73,3 +73,3 @@ "devDependencies": {

},
"gitHead": "8bd3de3f1dece95a0f026aa226a7dfe0dad55541"
"gitHead": "e0c1aaca24b51ee6ac5975291170d97229f26910"
}

@@ -61,3 +61,3 @@ /*

*/
export const inputStorageKeysFormatter = (keys: Array<string>) => keys.map(numberToHex);
export const inputStorageKeysFormatter = (keys: Array<string>) => keys.map(num => numberToHex(num));

@@ -64,0 +64,0 @@ /**

@@ -18,15 +18,15 @@ /*

export * from './web3_config';
export * from './web3_request_manager';
export * from './web3_subscription_manager';
export * from './web3_subscriptions';
export * from './web3_context';
export * from './web3_batch_request';
export * from './utils';
export * from './types';
export * from './formatters';
export * from './web3_promi_event';
export * from './web3_event_emitter';
export * from './web3_config.js';
export * from './web3_request_manager.js';
export * from './web3_subscription_manager.js';
export * from './web3_subscriptions.js';
export * from './web3_context.js';
export * from './web3_batch_request.js';
export * from './utils.js';
export * from './types.js';
export * from './formatters.js';
export * from './web3_promi_event.js';
export * from './web3_event_emitter.js';
// For backward usability export as namespace
export * as formatters from './formatters';
export * as formatters from './formatters.js';

@@ -21,3 +21,3 @@ /*

import { OperationAbortError, OperationTimeoutError, ResponseError } from 'web3-errors';
import { Web3RequestManager } from './web3_request_manager';
import { Web3RequestManager } from './web3_request_manager.js';

@@ -24,0 +24,0 @@ export const DEFAULT_BATCH_REQUEST_TIMEOUT = 1000;

@@ -21,6 +21,6 @@ /*

import { isNullish, toHex } from 'web3-utils';
import { TransactionTypeParser } from './types';
import { TransactionTypeParser } from './types.js';
// eslint-disable-next-line import/no-cycle
import { TransactionBuilder } from './web3_context';
import { Web3EventEmitter } from './web3_event_emitter';
import { TransactionBuilder } from './web3_context.js';
import { Web3EventEmitter } from './web3_event_emitter.js';

@@ -126,7 +126,3 @@ // To avoid cycle dependency declare this

public set handleRevert(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'handleRevert',
oldValue: this.config.handleRevert,
newValue: val,
});
this._triggerConfigChange('handleRevert', val);
this.config.handleRevert = val;

@@ -149,7 +145,3 @@ }

public set defaultAccount(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultAccount',
oldValue: this.config.defaultAccount,
newValue: val,
});
this._triggerConfigChange('defaultAccount', val);
this.config.defaultAccount = val;

@@ -182,7 +174,3 @@ }

public set defaultBlock(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'defaultBlock',
oldValue: this.config.defaultBlock,
newValue: val,
});
this._triggerConfigChange('defaultBlock', val);
this.config.defaultBlock = val;

@@ -204,7 +192,3 @@ }

public set transactionSendTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionSendTimeout',
oldValue: this.config.transactionSendTimeout,
newValue: val,
});
this._triggerConfigChange('transactionSendTimeout', val);
this.config.transactionSendTimeout = val;

@@ -225,7 +209,3 @@ }

public set transactionBlockTimeout(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionBlockTimeout',
oldValue: this.config.transactionBlockTimeout,
newValue: val,
});
this._triggerConfigChange('transactionBlockTimeout', val);
this.config.transactionBlockTimeout = val;

@@ -246,8 +226,3 @@ }

public set transactionConfirmationBlocks(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationBlocks',
oldValue: this.config.transactionConfirmationBlocks,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationBlocks', val);
this.config.transactionConfirmationBlocks = val;

@@ -268,8 +243,3 @@ }

public set transactionPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionPollingInterval',
oldValue: this.config.transactionPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionPollingInterval', val);
this.config.transactionPollingInterval = val;

@@ -309,8 +279,3 @@

public set transactionReceiptPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionReceiptPollingInterval',
oldValue: this.config.transactionReceiptPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionReceiptPollingInterval', val);
this.config.transactionReceiptPollingInterval = val;

@@ -324,8 +289,3 @@ }

public set transactionConfirmationPollingInterval(val) {
this.emit(Web3ConfigEvent.CONFIG_CHANGE, {
name: 'transactionConfirmationPollingInterval',
oldValue: this.config.transactionConfirmationPollingInterval,
newValue: val,
});
this._triggerConfigChange('transactionConfirmationPollingInterval', val);
this.config.transactionConfirmationPollingInterval = val;

@@ -335,3 +295,3 @@ }

/**
* 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.
* 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.
* Default is `10` seconds.

@@ -338,0 +298,0 @@ */

@@ -32,9 +32,9 @@ /*

import { isSupportedProvider } from './utils';
import { isSupportedProvider } from './utils.js';
// eslint-disable-next-line import/no-cycle
import { Web3Config, Web3ConfigEvent, Web3ConfigOptions } from './web3_config';
import { Web3RequestManager } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { Web3SubscriptionManager } from './web3_subscription_manager';
import { Web3BatchRequest } from './web3_batch_request';
import { Web3Config, Web3ConfigEvent, Web3ConfigOptions } from './web3_config.js';
import { Web3RequestManager } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
import { Web3SubscriptionManager } from './web3_subscription_manager.js';
import { Web3BatchRequest } from './web3_batch_request.js';

@@ -377,3 +377,4 @@ // To avoid circular dependencies, we need to export type from here.

web3Context: Web3Context<API>;
privateKey?: HexString | Buffer;
privateKey?: HexString | Uint8Array;
fillGasPrice?: boolean;
}) => Promise<ReturnType>;

@@ -380,0 +381,0 @@

@@ -23,3 +23,3 @@ /*

Web3EventMap,
} from './web3_event_emitter';
} from './web3_event_emitter.js';

@@ -26,0 +26,0 @@ export type PromiseExecutor<T> = (

@@ -53,4 +53,4 @@ /*

isWeb3Provider,
} from './utils';
import { Web3EventEmitter } from './web3_event_emitter';
} from './utils.js';
import { Web3EventEmitter } from './web3_event_emitter.js';

@@ -57,0 +57,0 @@ export enum Web3RequestManagerEvent {

@@ -21,5 +21,5 @@ /*

import { isNullish } from 'web3-utils';
import { isSupportSubscriptions } from './utils';
import { Web3RequestManager, Web3RequestManagerEvent } from './web3_request_manager';
import { Web3SubscriptionConstructor } from './web3_subscriptions';
import { isSupportSubscriptions } from './utils.js';
import { Web3RequestManager, Web3RequestManagerEvent } from './web3_request_manager.js';
import { Web3SubscriptionConstructor } from './web3_subscriptions.js';

@@ -26,0 +26,0 @@ type ShouldUnsubscribeCondition = ({

@@ -31,7 +31,9 @@ /*

DEFAULT_RETURN_FORMAT,
JsonRpcSubscriptionResultOld,
EIP1193Provider,
} from 'web3-types';
import { jsonRpc } from 'web3-utils';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter';
import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter.js';
import { Web3RequestManager } from './web3_request_manager';
import { Web3RequestManager } from './web3_request_manager.js';

@@ -48,3 +50,3 @@ export abstract class Web3Subscription<

private _id?: HexString;
private _messageListener?: (e: Error | undefined, data?: JsonRpcNotification<Log>) => void;
private _messageListener?: (data?: JsonRpcNotification<Log>) => void;

@@ -76,14 +78,28 @@ public constructor(

const messageListener = (
err: Error | undefined,
data?: JsonRpcSubscriptionResult | JsonRpcNotification<Log>,
data?:
| JsonRpcSubscriptionResult
| JsonRpcSubscriptionResultOld<Log>
| JsonRpcNotification<Log>,
) => {
if (data && jsonRpc.isResponseWithNotification(data)) {
// for EIP-1193 provider
if (data?.data) {
this._processSubscriptionResult(data?.data?.result ?? data?.data);
return;
}
if (
data &&
jsonRpc.isResponseWithNotification(
data as unknown as JsonRpcSubscriptionResult | JsonRpcNotification<Log>,
)
) {
this._processSubscriptionResult(data?.params.result);
}
if (err) {
this._processSubscriptionError(err);
}
};
(this._requestManager.provider as Web3BaseProvider).on<Log>('message', messageListener);
if (typeof (this._requestManager.provider as EIP1193Provider<API>).request === 'function') {
(this._requestManager.provider as Web3BaseProvider).on<Log>('message', messageListener);
} else {
(this._requestManager.provider as Web3BaseProvider).on<Log>('data', messageListener);
}

@@ -90,0 +106,0 @@ this._messageListener = messageListener;

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc