Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
* source https://github.com/MCROEngineering/zoom/
* @name HttpProvider
* @package ZoomDev
* @author Micky Socaci
* @license MIT
based on https://github.com/ethereum/web3.js/blob/develop/lib/web3/httpprovider.js
*/
import CryptoJS from "crypto-js";
const errors = require('web3-core-helpers').errors;
const XHR2 = require('xhr2-cookies').XMLHttpRequest; // jshint ignore: line
export default class HttpProvider {
public cache: any;
public hits: number = 0;
public requests: any = [];
private host: string;
private timeout: number;
private headers: any;
private connected: boolean = false;
private usecache: boolean = false;
constructor(host?: any, options?: any) {
options = options || {};
this.host = host || 'http://localhost:8545';
/*
* source https://github.com/MCROEngineering/zoom/
* @name HttpProvider
* @package ZoomDev
* @author Micky Socaci
* @license MIT
based on https://github.com/ethereum/web3.js/blob/develop/lib/web3/httpprovider.js
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var crypto_js_1 = __importDefault(require("crypto-js"));
var errors = require('web3-core-helpers').errors;
var XHR2 = require('xhr2-cookies').XMLHttpRequest; // jshint ignore: line
var HttpProvider = /** @class */ (function () {
function HttpProvider(host, options) {
this.hits = 0;
this.requests = [];
this.connected = false;
this.usecache = false;
options = options || {};
this.host = host || 'http://localhost:8545';
this.timeout = options.timeout || 0;
this.headers = options.headers;
this.cache = {};
}
/**
* Create and return a new XMLHttpRequest
*
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require('underscore');
var errors = require('web3-core-helpers').errors;
var Ws = null;
var parseURL = null;
var myBtoa = null;
// @ts-ignore: WebSocket
/*
if (typeof window !== 'undefined' && typeof window.WebSocket !== 'undefined') {
// @ts-ignore: WebSocket
Ws = window.WebSocket;
myBtoa = btoa;
parseURL = (iurl: any) => {
return new URL(iurl);
};
} else {
*/
Ws = require('websocket').w3cwebsocket;
myBtoa = function (str) {
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see .
*/
/** @file httpprovider.js
* @authors:
* Marek Kotewicz
* Marian Oancea
* Fabian Vogelsteller
* @date 2015
*/
var errors = require('web3-core-helpers').errors;
var XHR2 = require('xhr2-cookies').XMLHttpRequest; // jshint ignore: line
var http = require('http');
var https = require('https');
/**
* HttpProvider should be used to send rpc calls over http
*/
var HttpProvider = function HttpProvider(host, options) {
options = options || {};
var keepAlive = (options.keepAlive === true || options.keepAlive !== false) ? true : false;
this.host = host || 'http://localhost:8545';
if (this.host.substring(0,5) === "https") {
this.httpsAgent = new https.Agent({ keepAlive: keepAlive });
} else {
const _ = require('underscore');
const errors = require('web3-core-helpers').errors;
let Ws: any = null;
let parseURL: any = null;
let myBtoa: any = null;
// @ts-ignore: WebSocket
/*
if (typeof window !== 'undefined' && typeof window.WebSocket !== 'undefined') {
// @ts-ignore: WebSocket
Ws = window.WebSocket;
myBtoa = btoa;
parseURL = (iurl: any) => {
return new URL(iurl);
};
} else {
*/
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see .
*/
/**
* @file index.js
* @author Fabian Vogelsteller
* @author Marek Kotewicz
* @date 2017
*/
"use strict";
var _ = require('underscore');
var errors = require('web3-core-helpers').errors;
var formatters = require('web3-core-helpers').formatters;
var utils = require('web3-utils');
var promiEvent = require('web3-core-promievent');
var Subscriptions = require('web3-core-subscriptions').subscriptions;
var TIMEOUTBLOCK = 50;
var POLLINGTIMEOUT = 15 * TIMEOUTBLOCK; // ~average block time (seconds) * TIMEOUTBLOCK
var CONFIRMATIONBLOCKS = 24;
var Method = function Method(options) {
if(!options.call || !options.name) {
throw new Error('When creating a method you need to provide at least the "name" and "call" property.');
}
this.name = options.name;
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see .
*/
/**
* @file subscription.js
* @author Fabian Vogelsteller
* @date 2017
*/
"use strict";
var _ = require('underscore');
var errors = require('web3-core-helpers').errors;
var EventEmitter = require('eventemitter3');
function Subscription(options) {
EventEmitter.call(this);
this.id = null;
this.callback = null;
this.arguments = null;
this._reconnectIntervalId = null;
this.options = {
subscription: options.subscription,
type: options.type,
requestManager: options.requestManager
};
CoreFactory.prototype.createErrors = function () {
return helpers.errors;
};
'use strict';
const _ = require('underscore');
const errors = require('web3-core-helpers').errors;
let Ws = null;
let _btoa = null;
let parseURL = null;
Ws = function(url, protocols) {
if (protocols) return new window.WebSocket(url, protocols);
return new window.WebSocket(url);
};
_btoa = btoa;
parseURL = function(url) {
return new URL(url);
};
const WebsocketProvider = function WebsocketProvider(url, options) {
const _this = this;
this.responseCallbacks = {};
this.notificationCallbacks = [];
*
* @author Fabian Vogelsteller
* @date 2017
*/
"use strict";
var _ = require('underscore');
var core = require('web3-core');
var Method = require('web3-core-method');
var utils = require('web3-utils');
var Subscription = require('web3-core-subscriptions').subscription;
var formatters = require('web3-core-helpers').formatters;
var errors = require('web3-core-helpers').errors;
var promiEvent = require('web3-core-promievent');
var abi = require('web3-eth-abi');
var ens = require('web3-eth-ens');
/**
* Should be called to create new contract instance
*
* @method Contract
* @constructor
* @param {Array} jsonInterface
* @param {String} address
* @param {Object} options
*/
var Contract = function Contract(jsonInterface, address, options) {
var _this = this,