Readd semicolon, and build
This commit is contained in:
parent
c774f90866
commit
e7641a7add
|
@ -3655,6 +3655,8 @@ module.exports = Filter;
|
|||
|
||||
|
||||
},{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
|
||||
'use strict'
|
||||
|
||||
/*
|
||||
This file is part of web3.js.
|
||||
|
||||
|
@ -3847,11 +3849,11 @@ var outputBlockFormatter = function(block) {
|
|||
* @returns {Object} log
|
||||
*/
|
||||
var outputLogFormatter = function(log) {
|
||||
if(log.blockNumber !== null)
|
||||
if(log.blockNumber)
|
||||
log.blockNumber = utils.toDecimal(log.blockNumber);
|
||||
if(log.transactionIndex !== null)
|
||||
if(log.transactionIndex)
|
||||
log.transactionIndex = utils.toDecimal(log.transactionIndex);
|
||||
if(log.logIndex !== null)
|
||||
if(log.logIndex)
|
||||
log.logIndex = utils.toDecimal(log.logIndex);
|
||||
|
||||
return log;
|
||||
|
@ -3930,6 +3932,9 @@ var inputAddressFormatter = function (address) {
|
|||
|
||||
|
||||
var outputSyncingFormatter = function(result) {
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.startingBlock = utils.toDecimal(result.startingBlock);
|
||||
result.currentBlock = utils.toDecimal(result.currentBlock);
|
||||
|
@ -4269,27 +4274,28 @@ module.exports = SolidityFunction;
|
|||
* @date 2015
|
||||
*/
|
||||
|
||||
|
||||
var errors = require('./errors');
|
||||
var errors = require('./errors')
|
||||
|
||||
// workaround to use httpprovider in different envs
|
||||
|
||||
// browser
|
||||
if (typeof window !== 'undefined' && window.XMLHttpRequest) {
|
||||
XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
|
||||
XMLHttpRequest = window.XMLHttpRequest // jshint ignore: line
|
||||
// node
|
||||
} else {
|
||||
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
|
||||
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest // jshint ignore: line
|
||||
}
|
||||
|
||||
var XHR2 = require('xhr2'); // jshint ignore: line
|
||||
var XHR2 = require('xhr2') // jshint ignore: line
|
||||
|
||||
/**
|
||||
* HttpProvider should be used to send rpc calls over http
|
||||
*/
|
||||
var HttpProvider = function (host, timeout) {
|
||||
this.host = host || 'http://localhost:8545';
|
||||
this.timeout = timeout || 0;
|
||||
var HttpProvider = function (host, timeout, user, password) {
|
||||
this.host = host || 'http://localhost:8545';
|
||||
this.timeout = timeout || 0;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4300,18 +4306,18 @@ var HttpProvider = function (host, timeout) {
|
|||
* @return {XMLHttpRequest} object
|
||||
*/
|
||||
HttpProvider.prototype.prepareRequest = function (async) {
|
||||
var request;
|
||||
var request;
|
||||
|
||||
if (async) {
|
||||
request = new XHR2();
|
||||
request.timeout = this.timeout;
|
||||
}else {
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
if (async) {
|
||||
request = new XHR2();
|
||||
request.timeout = this.timeout;
|
||||
} else {
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
|
||||
request.open('POST', this.host, async);
|
||||
request.setRequestHeader('Content-Type','application/json');
|
||||
return request;
|
||||
request.open('POST', this.host, async, this.user, this.password);
|
||||
request.setRequestHeader('Content-Type', 'application/json');
|
||||
return request;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4322,23 +4328,23 @@ HttpProvider.prototype.prepareRequest = function (async) {
|
|||
* @return {Object} result
|
||||
*/
|
||||
HttpProvider.prototype.send = function (payload) {
|
||||
var request = this.prepareRequest(false);
|
||||
var request = this.prepareRequest(false);
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch(error) {
|
||||
throw errors.InvalidConnection(this.host);
|
||||
}
|
||||
try {
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch (error) {
|
||||
throw errors.InvalidConnection(this.host);
|
||||
}
|
||||
|
||||
var result = request.responseText;
|
||||
var result = request.responseText;
|
||||
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch (e) {
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4349,32 +4355,32 @@ HttpProvider.prototype.send = function (payload) {
|
|||
* @param {Function} callback triggered on end with (err, result)
|
||||
*/
|
||||
HttpProvider.prototype.sendAsync = function (payload, callback) {
|
||||
var request = this.prepareRequest(true);
|
||||
var request = this.prepareRequest(true);
|
||||
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState === 4 && request.timeout !== 1) {
|
||||
var result = request.responseText;
|
||||
var error = null;
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4 && request.timeout !== 1) {
|
||||
var result = request.responseText;
|
||||
var error = null;
|
||||
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch (e) {
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
callback(error, result);
|
||||
}
|
||||
};
|
||||
|
||||
request.ontimeout = function() {
|
||||
callback(errors.ConnectionTimeout(this.timeout));
|
||||
};
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch(error) {
|
||||
callback(errors.InvalidConnection(this.host));
|
||||
callback(error, result);
|
||||
}
|
||||
};
|
||||
|
||||
request.ontimeout = function () {
|
||||
callback(errors.ConnectionTimeout(this.timeout));
|
||||
};
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch (error) {
|
||||
callback(errors.InvalidConnection(this.host));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4383,18 +4389,18 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
|
|||
* @method isConnected
|
||||
* @return {Boolean} returns true if request haven't failed. Otherwise false
|
||||
*/
|
||||
HttpProvider.prototype.isConnected = function() {
|
||||
try {
|
||||
this.send({
|
||||
id: 9999999999,
|
||||
jsonrpc: '2.0',
|
||||
method: 'net_listening',
|
||||
params: []
|
||||
});
|
||||
return true;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
HttpProvider.prototype.isConnected = function () {
|
||||
try {
|
||||
this.send({
|
||||
id: 9999999999,
|
||||
jsonrpc: '2.0',
|
||||
method: 'net_listening',
|
||||
params: []
|
||||
});
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = HttpProvider;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -40,11 +40,11 @@ var XHR2 = require('xhr2') // jshint ignore: line
|
|||
* HttpProvider should be used to send rpc calls over http
|
||||
*/
|
||||
var HttpProvider = function (host, timeout, user, password) {
|
||||
this.host = host || 'http://localhost:8545'
|
||||
this.timeout = timeout || 0
|
||||
this.user = user
|
||||
this.password = password
|
||||
}
|
||||
this.host = host || 'http://localhost:8545';
|
||||
this.timeout = timeout || 0;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to prepare new XMLHttpRequest
|
||||
|
@ -54,19 +54,19 @@ var HttpProvider = function (host, timeout, user, password) {
|
|||
* @return {XMLHttpRequest} object
|
||||
*/
|
||||
HttpProvider.prototype.prepareRequest = function (async) {
|
||||
var request
|
||||
var request;
|
||||
|
||||
if (async) {
|
||||
request = new XHR2()
|
||||
request.timeout = this.timeout
|
||||
request = new XHR2();
|
||||
request.timeout = this.timeout;
|
||||
} else {
|
||||
request = new XMLHttpRequest()
|
||||
request = new XMLHttpRequest();
|
||||
}
|
||||
|
||||
request.open('POST', this.host, async, this.user, this.password)
|
||||
request.setRequestHeader('Content-Type', 'application/json')
|
||||
return request
|
||||
}
|
||||
request.open('POST', this.host, async, this.user, this.password);
|
||||
request.setRequestHeader('Content-Type', 'application/json');
|
||||
return request;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to make sync request
|
||||
|
@ -76,24 +76,24 @@ HttpProvider.prototype.prepareRequest = function (async) {
|
|||
* @return {Object} result
|
||||
*/
|
||||
HttpProvider.prototype.send = function (payload) {
|
||||
var request = this.prepareRequest(false)
|
||||
var request = this.prepareRequest(false);
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload))
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch (error) {
|
||||
throw errors.InvalidConnection(this.host)
|
||||
throw errors.InvalidConnection(this.host);
|
||||
}
|
||||
|
||||
var result = request.responseText
|
||||
var result = request.responseText;
|
||||
|
||||
try {
|
||||
result = JSON.parse(result)
|
||||
result = JSON.parse(result);
|
||||
} catch (e) {
|
||||
throw errors.InvalidResponse(request.responseText)
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to make async request
|
||||
|
@ -103,33 +103,33 @@ HttpProvider.prototype.send = function (payload) {
|
|||
* @param {Function} callback triggered on end with (err, result)
|
||||
*/
|
||||
HttpProvider.prototype.sendAsync = function (payload, callback) {
|
||||
var request = this.prepareRequest(true)
|
||||
var request = this.prepareRequest(true);
|
||||
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4 && request.timeout !== 1) {
|
||||
var result = request.responseText
|
||||
var error = null
|
||||
var result = request.responseText;
|
||||
var error = null;
|
||||
|
||||
try {
|
||||
result = JSON.parse(result)
|
||||
result = JSON.parse(result);
|
||||
} catch (e) {
|
||||
error = errors.InvalidResponse(request.responseText)
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
callback(error, result)
|
||||
callback(error, result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.ontimeout = function () {
|
||||
callback(errors.ConnectionTimeout(this.timeout))
|
||||
}
|
||||
callback(errors.ConnectionTimeout(this.timeout));
|
||||
};
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload))
|
||||
request.send(JSON.stringify(payload));
|
||||
} catch (error) {
|
||||
callback(errors.InvalidConnection(this.host))
|
||||
callback(errors.InvalidConnection(this.host));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Synchronously tries to make Http request
|
||||
|
@ -144,11 +144,11 @@ HttpProvider.prototype.isConnected = function () {
|
|||
jsonrpc: '2.0',
|
||||
method: 'net_listening',
|
||||
params: []
|
||||
})
|
||||
});
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = HttpProvider
|
||||
module.exports = HttpProvider;
|
||||
|
|
Loading…
Reference in New Issue