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

conflux-web-core

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conflux-web-core - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

224

dist/conflux-web-core.esm.js
import isObject from 'lodash/isObject';
import { ProviderResolver, ProviderDetector, BatchRequest, HttpProvider, WebsocketProvider, IpcProvider } from 'conflux-web-providers';
import { HttpProvider, WebsocketProvider, IpcProvider, ProviderResolver, ProviderDetector, BatchRequest } from 'conflux-web-providers';
import { MethodProxy } from 'conflux-web-core-method';
import { toChecksumAddress } from 'conflux-web-utils';
class AbstractConfluxWebModule {
constructor(provider, options = {}, methodFactory = null, nodeNet = null) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var AbstractConfluxWebModule =
function () {
function AbstractConfluxWebModule(provider) {
var _this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var methodFactory = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var nodeNet = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
_classCallCheck(this, AbstractConfluxWebModule);
this.providerResolver = new ProviderResolver();

@@ -18,4 +46,4 @@ this.givenProvider = ProviderDetector.detect();

this._defaultGas = options.defaultGas;
this.BatchRequest = () => {
return new BatchRequest(this);
this.BatchRequest = function () {
return new BatchRequest(_this);
};

@@ -26,83 +54,117 @@ if (methodFactory) {

}
get defaultEpoch() {
return this._defaultEpoch;
}
set defaultEpoch(value) {
this._defaultEpoch = value;
}
get transactionBlockTimeout() {
return this._transactionBlockTimeout;
}
set transactionBlockTimeout(value) {
this._transactionBlockTimeout = value;
}
get transactionConfirmationBlocks() {
return this._transactionConfirmationBlocks;
}
set transactionConfirmationBlocks(value) {
this._transactionConfirmationBlocks = value;
}
get transactionPollingTimeout() {
return this._transactionPollingTimeout;
}
set transactionPollingTimeout(value) {
this._transactionPollingTimeout = value;
}
get defaultGasPrice() {
return this._defaultGasPrice;
}
set defaultGasPrice(value) {
this._defaultGasPrice = value;
}
get defaultGas() {
return this._defaultGas;
}
set defaultGas(value) {
this._defaultGas = value;
}
static get providers() {
return {
HttpProvider,
WebsocketProvider,
IpcProvider
};
}
get defaultAccount() {
return this._defaultAccount;
}
set defaultAccount(value) {
this._defaultAccount = toChecksumAddress(value);
}
get currentProvider() {
return this._currentProvider;
}
set currentProvider(value) {
throw new Error('The property currentProvider is read-only!');
}
setProvider(provider, net) {
if (!this.isSameProvider(provider)) {
const resolvedProvider = this.providerResolver.resolve(provider, net);
this.clearSubscriptions();
this._currentProvider = resolvedProvider;
return true;
}
return false;
}
isSameProvider(provider) {
if (isObject(provider)) {
if (this.currentProvider.constructor.name === provider.constructor.name) {
return this.currentProvider.host === provider.host;
_createClass(AbstractConfluxWebModule, [{
key: "setProvider",
value: function setProvider(provider, net) {
if (!this.isSameProvider(provider)) {
var resolvedProvider = this.providerResolver.resolve(provider, net);
this.clearSubscriptions();
this._currentProvider = resolvedProvider;
return true;
}
return false;
}
return this.currentProvider.host === provider;
}
clearSubscriptions(unsubscribeMethod) {
if (typeof this.currentProvider.clearSubscriptions !== 'undefined' && this.currentProvider.subscriptions.length > 0) {
return this.currentProvider.clearSubscriptions(unsubscribeMethod);
}, {
key: "isSameProvider",
value: function isSameProvider(provider) {
if (isObject(provider)) {
if (this.currentProvider.constructor.name === provider.constructor.name) {
return this.currentProvider.host === provider.host;
}
return false;
}
return this.currentProvider.host === provider;
}
return Promise.resolve(true);
}
}
}, {
key: "clearSubscriptions",
value: function clearSubscriptions(unsubscribeMethod) {
if (typeof this.currentProvider.clearSubscriptions !== 'undefined' && this.currentProvider.subscriptions.length > 0) {
return this.currentProvider.clearSubscriptions(unsubscribeMethod);
}
return Promise.resolve(true);
}
}, {
key: "defaultEpoch",
get: function get() {
return this._defaultEpoch;
}
,
set: function set(value) {
this._defaultEpoch = value;
}
}, {
key: "transactionBlockTimeout",
get: function get() {
return this._transactionBlockTimeout;
}
,
set: function set(value) {
this._transactionBlockTimeout = value;
}
}, {
key: "transactionConfirmationBlocks",
get: function get() {
return this._transactionConfirmationBlocks;
}
,
set: function set(value) {
this._transactionConfirmationBlocks = value;
}
}, {
key: "transactionPollingTimeout",
get: function get() {
return this._transactionPollingTimeout;
}
,
set: function set(value) {
this._transactionPollingTimeout = value;
}
}, {
key: "defaultGasPrice",
get: function get() {
return this._defaultGasPrice;
}
,
set: function set(value) {
this._defaultGasPrice = value;
}
}, {
key: "defaultGas",
get: function get() {
return this._defaultGas;
}
,
set: function set(value) {
this._defaultGas = value;
}
}, {
key: "defaultAccount",
get: function get() {
return this._defaultAccount;
}
,
set: function set(value) {
this._defaultAccount = toChecksumAddress(value);
}
}, {
key: "currentProvider",
get: function get() {
return this._currentProvider;
}
,
set: function set(value) {
throw new Error('The property currentProvider is read-only!');
}
}], [{
key: "providers",
get: function get() {
return {
HttpProvider: HttpProvider,
WebsocketProvider: WebsocketProvider,
IpcProvider: IpcProvider
};
}
}]);
return AbstractConfluxWebModule;
}();
export { AbstractConfluxWebModule };
{
"name": "conflux-web-core",
"version": "0.1.6",
"version": "0.1.7",
"description": "ConfluxWeb core tools for sub packages. This is an internal package.",

@@ -21,10 +21,10 @@ "repository": "https://github.com/Conflux-Chain/ConfluxWeb/tree/master/packages/conflux-web-core",

"@types/node": "^10.12.18",
"conflux-web-core-method": "0.1.6",
"conflux-web-providers": "0.1.6",
"conflux-web-utils": "0.1.6",
"conflux-web-core-method": "0.1.7",
"conflux-web-providers": "0.1.7",
"conflux-web-utils": "0.1.7",
"lodash": "^4.17.11"
},
"devDependencies": {
"conflux-web-cfx-accounts": "0.1.6",
"conflux-web-core-subscriptions": "0.1.6",
"conflux-web-cfx-accounts": "0.1.7",
"conflux-web-core-subscriptions": "0.1.7",
"definitelytyped-header-parser": "^1.0.1",

@@ -38,3 +38,3 @@ "dtslint": "0.4.2",

],
"gitHead": "06c54abcd2af635eb22536f9cb2e2fa8a8b62ad2"
"gitHead": "5bd1d26ba861ce65bc21c652bb7ec28642a173a5"
}
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