web3
Advanced tools
Comparing version 0.14.1 to 0.15.0
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"description": "Ethereum Compatible JavaScript API", | ||
@@ -6,0 +6,0 @@ "main": [ |
#!/usr/bin/env node | ||
var web3 = require("../index.js"); | ||
var Web3 = require('../index.js'); | ||
var web3 = new Web3(); | ||
@@ -5,0 +6,0 @@ web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); |
{ | ||
"version": "0.14.1" | ||
"version": "0.15.0" | ||
} |
@@ -30,4 +30,4 @@ /* | ||
var AllSolidityEvents = function (web3, json, address) { | ||
this._web3 = web3; | ||
var AllSolidityEvents = function (requestManager, json, address) { | ||
this._requestManager = requestManager; | ||
this._json = json; | ||
@@ -66,3 +66,3 @@ this._address = address; | ||
var event = new SolidityEvent(this._web3, match, this._address); | ||
var event = new SolidityEvent(this._requestManager, match, this._address); | ||
return event.decode(data); | ||
@@ -81,3 +81,3 @@ }; | ||
var formatter = this.decode.bind(this); | ||
return new Filter(this._web3, o, watches.eth(), formatter, callback); | ||
return new Filter(this._requestManager, o, watches.eth(), formatter, callback); | ||
}; | ||
@@ -84,0 +84,0 @@ |
@@ -59,3 +59,3 @@ /* | ||
}).map(function (json) { | ||
return new SolidityFunction(contract._web3, json, contract.address); | ||
return new SolidityFunction(contract._eth, json, contract.address); | ||
}).forEach(function (f) { | ||
@@ -78,7 +78,7 @@ f.attachToContract(contract); | ||
var All = new AllEvents(contract._web3, events, contract.address); | ||
var All = new AllEvents(contract._eth._requestManager, events, contract.address); | ||
All.attachToContract(contract); | ||
events.map(function (json) { | ||
return new SolidityEvent(contract._web3, json, contract.address); | ||
return new SolidityEvent(contract._eth._requestManager, json, contract.address); | ||
}).forEach(function (e) { | ||
@@ -103,3 +103,3 @@ e.attachToContract(contract); | ||
// wait for receipt | ||
var filter = contract._web3.eth.filter('latest', function(e){ | ||
var filter = contract._eth.filter('latest', function(e){ | ||
if (!e && !callbackFired) { | ||
@@ -122,9 +122,9 @@ count++; | ||
contract._web3.eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){ | ||
contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){ | ||
if(receipt && !callbackFired) { | ||
contract._web3.eth.getCode(receipt.contractAddress, function(e, code){ | ||
/*jshint maxcomplexity: 5 */ | ||
contract._eth.getCode(receipt.contractAddress, function(e, code){ | ||
/*jshint maxcomplexity: 6 */ | ||
if(callbackFired) | ||
if(callbackFired || !code) | ||
return; | ||
@@ -169,5 +169,7 @@ | ||
*/ | ||
var ContractFactory = function (web3, abi) { | ||
this.web3 = web3; | ||
var ContractFactory = function (eth, abi) { | ||
this.eth = eth; | ||
this.abi = abi; | ||
this.new.getData = this.getData.bind(this); | ||
}; | ||
@@ -197,3 +199,3 @@ | ||
ContractFactory.prototype.new = function () { | ||
var contract = new Contract(this.web3, this.abi); | ||
var contract = new Contract(this.eth, this.abi); | ||
@@ -220,3 +222,3 @@ // parse arguments | ||
// wait for the contract address adn check if the code was deployed | ||
this.web3.eth.sendTransaction(options, function (err, hash) { | ||
this.eth.sendTransaction(options, function (err, hash) { | ||
if (err) { | ||
@@ -235,3 +237,3 @@ callback(err); | ||
} else { | ||
var hash = this.web3.eth.sendTransaction(options); | ||
var hash = this.eth.sendTransaction(options); | ||
// add the transaction hash | ||
@@ -255,3 +257,3 @@ contract.transactionHash = hash; | ||
ContractFactory.prototype.at = function (address, callback) { | ||
var contract = new Contract(this.web3, this.abi, address); | ||
var contract = new Contract(this.eth, this.abi, address); | ||
@@ -270,2 +272,22 @@ // this functions are not part of prototype, | ||
/** | ||
* Gets the data, which is data to deploy plus constructor params | ||
* | ||
* @method getData | ||
*/ | ||
ContractFactory.prototype.getData = function () { | ||
var options = {}; // required! | ||
var args = Array.prototype.slice.call(arguments); | ||
var last = args[args.length - 1]; | ||
if (utils.isObject(last) && !utils.isArray(last)) { | ||
options = args.pop(); | ||
} | ||
var bytes = encodeConstructorParams(this.abi, args); | ||
options.data += bytes; | ||
return options.data; | ||
}; | ||
/** | ||
* Should be called to create new contract instance | ||
@@ -277,4 +299,4 @@ * | ||
*/ | ||
var Contract = function (web3, abi, address) { | ||
this._web3 = web3; | ||
var Contract = function (eth, abi, address) { | ||
this._eth = eth; | ||
this.transactionHash = null; | ||
@@ -281,0 +303,0 @@ this.address = address; |
@@ -33,4 +33,4 @@ /* | ||
*/ | ||
var SolidityEvent = function (web3, json, address) { | ||
this._web3 = web3; | ||
var SolidityEvent = function (requestManager, json, address) { | ||
this._requestManager = requestManager; | ||
this._params = json.inputs; | ||
@@ -190,3 +190,3 @@ this._name = utils.transformToFullName(json); | ||
var formatter = this.decode.bind(this); | ||
return new Filter(this._web3, o, watches.eth(), formatter, callback); | ||
return new Filter(this._requestManager, o, watches.eth(), formatter, callback); | ||
}; | ||
@@ -193,0 +193,0 @@ |
@@ -133,10 +133,10 @@ /* | ||
var Filter = function (web3, options, methods, formatter, callback) { | ||
var Filter = function (requestManager, options, methods, formatter, callback) { | ||
var self = this; | ||
var implementation = {}; | ||
methods.forEach(function (method) { | ||
method.setRequestManager(web3._requestManager); | ||
method.setRequestManager(requestManager); | ||
method.attachToObject(implementation); | ||
}); | ||
this.requestManager = web3._requestManager; | ||
this.requestManager = requestManager; | ||
this.options = getOptions(options); | ||
@@ -143,0 +143,0 @@ this.implementation = implementation; |
@@ -31,4 +31,4 @@ /* | ||
*/ | ||
var SolidityFunction = function (web3, json, address) { | ||
this._web3 = web3; | ||
var SolidityFunction = function (eth, json, address) { | ||
this._eth = eth; | ||
this._inputTypes = json.inputs.map(function (i) { | ||
@@ -113,3 +113,3 @@ return i.type; | ||
if (!callback) { | ||
var output = this._web3.eth.call(payload, defaultBlock); | ||
var output = this._eth.call(payload, defaultBlock); | ||
return this.unpackOutput(output); | ||
@@ -119,3 +119,3 @@ } | ||
var self = this; | ||
this._web3.eth.call(payload, defaultBlock, function (error, output) { | ||
this._eth.call(payload, defaultBlock, function (error, output) { | ||
callback(error, self.unpackOutput(output)); | ||
@@ -129,3 +129,2 @@ }); | ||
* @method sendTransaction | ||
* @param {Object} options | ||
*/ | ||
@@ -138,6 +137,6 @@ SolidityFunction.prototype.sendTransaction = function () { | ||
if (!callback) { | ||
return this._web3.eth.sendTransaction(payload); | ||
return this._eth.sendTransaction(payload); | ||
} | ||
this._web3.eth.sendTransaction(payload, callback); | ||
this._eth.sendTransaction(payload, callback); | ||
}; | ||
@@ -149,3 +148,2 @@ | ||
* @method estimateGas | ||
* @param {Object} options | ||
*/ | ||
@@ -158,9 +156,22 @@ SolidityFunction.prototype.estimateGas = function () { | ||
if (!callback) { | ||
return this._web3.eth.estimateGas(payload); | ||
return this._eth.estimateGas(payload); | ||
} | ||
this._web3.eth.estimateGas(payload, callback); | ||
this._eth.estimateGas(payload, callback); | ||
}; | ||
/** | ||
* Return the encoded data of the call | ||
* | ||
* @method getData | ||
* @return {String} the encoded data | ||
*/ | ||
SolidityFunction.prototype.getData = function () { | ||
var args = Array.prototype.slice.call(arguments); | ||
var payload = this.toPayload(args); | ||
return payload.data; | ||
}; | ||
/** | ||
* Should be used to get function display name | ||
@@ -234,2 +245,3 @@ * | ||
execute.estimateGas = this.estimateGas.bind(this); | ||
execute.getData = this.getData.bind(this); | ||
var displayName = this.displayName(); | ||
@@ -236,0 +248,0 @@ if (!contract[displayName]) { |
@@ -60,3 +60,3 @@ /* | ||
function Eth(web3) { | ||
this.web3 = web3; | ||
this._requestManager = web3._requestManager; | ||
@@ -67,3 +67,3 @@ var self = this; | ||
method.attachToObject(self); | ||
method.setRequestManager(web3._requestManager); | ||
method.setRequestManager(self._requestManager); | ||
}); | ||
@@ -73,9 +73,8 @@ | ||
p.attachToObject(self); | ||
p.setRequestManager(web3._requestManager); | ||
p.setRequestManager(self._requestManager); | ||
}); | ||
this.namereg = this.contract(namereg.global.abi).at(namereg.global.address); | ||
this.icapNamereg = this.contract(namereg.icap.abi).at(namereg.icap.address); | ||
this.iban = Iban; | ||
this.sendIBANTransaction = transfer.bind(null, web3); | ||
this.sendIBANTransaction = transfer.bind(null, this); | ||
} | ||
@@ -318,3 +317,3 @@ | ||
Eth.prototype.contract = function (abi) { | ||
var factory = new Contract(this.web3, abi); | ||
var factory = new Contract(this, abi); | ||
return factory; | ||
@@ -324,7 +323,15 @@ }; | ||
Eth.prototype.filter = function (fil, callback) { | ||
return new Filter(this.web3, fil, watches.eth(), formatters.outputLogFormatter, callback); | ||
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback); | ||
}; | ||
Eth.prototype.namereg = function () { | ||
return this.contract(namereg.global.abi).at(namereg.global.address); | ||
}; | ||
Eth.prototype.icapNamereg = function () { | ||
return this.contract(namereg.icap.abi).at(namereg.icap.address); | ||
}; | ||
Eth.prototype.isSyncing = function (callback) { | ||
return new IsSyncing(this.web3, callback); | ||
return new IsSyncing(this._requestManager, callback); | ||
}; | ||
@@ -331,0 +338,0 @@ |
@@ -29,3 +29,3 @@ /* | ||
var Shh = function (web3) { | ||
this.web3 = web3; | ||
this._requestManager = web3._requestManager; | ||
@@ -36,3 +36,3 @@ var self = this; | ||
method.attachToObject(self); | ||
method.setRequestManager(web3._requestManager); | ||
method.setRequestManager(self._requestManager); | ||
}); | ||
@@ -42,3 +42,3 @@ }; | ||
Shh.prototype.filter = function (fil, callback) { | ||
return new Filter(this.web3, fil, watches.shh(), formatters.outputPostFormatter, callback); | ||
return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback); | ||
}; | ||
@@ -45,0 +45,0 @@ |
@@ -43,3 +43,3 @@ /* | ||
if(utils.isObject(sync)) | ||
if(utils.isObject(sync) && sync.startingBlock) | ||
sync = formatters.outputSyncingFormatter(sync); | ||
@@ -71,5 +71,4 @@ | ||
var IsSyncing = function (web3, callback) { | ||
this._web3 = web3; | ||
this.requestManager = web3._requestManager; | ||
var IsSyncing = function (requestManager, callback) { | ||
this.requestManager = requestManager; | ||
this.pollId = 'syncPoll_'+ count++; | ||
@@ -91,3 +90,3 @@ this.callbacks = []; | ||
IsSyncing.prototype.stopWatching = function () { | ||
this._web3._requestManager.stopPolling(this.pollId); | ||
this.requestManager.stopPolling(this.pollId); | ||
this.callbacks = []; | ||
@@ -94,0 +93,0 @@ }; |
@@ -35,3 +35,3 @@ /* | ||
*/ | ||
var transfer = function (web3, from, to, value, callback) { | ||
var transfer = function (eth, from, to, value, callback) { | ||
var iban = new Iban(to); | ||
@@ -43,12 +43,12 @@ if (!iban.isValid()) { | ||
if (iban.isDirect()) { | ||
return transferToAddress(web3, from, iban.address(), value, callback); | ||
return transferToAddress(eth, from, iban.address(), value, callback); | ||
} | ||
if (!callback) { | ||
var address = web3.eth.icapNamereg.addr(iban.institution()); | ||
return deposit(web3, from, address, value, iban.client()); | ||
var address = eth.icapNamereg().addr(iban.institution()); | ||
return deposit(eth, from, address, value, iban.client()); | ||
} | ||
web3.eth.icapNamereg.addr(iban.institution(), function (err, address) { | ||
return deposit(web3, from, address, value, iban.client(), callback); | ||
eth.icapNamereg().addr(iban.institution(), function (err, address) { | ||
return deposit(eth, from, address, value, iban.client(), callback); | ||
}); | ||
@@ -67,4 +67,4 @@ | ||
*/ | ||
var transferToAddress = function (web3, from, to, value, callback) { | ||
return web3.eth.sendTransaction({ | ||
var transferToAddress = function (eth, from, to, value, callback) { | ||
return eth.sendTransaction({ | ||
address: to, | ||
@@ -86,5 +86,5 @@ from: from, | ||
*/ | ||
var deposit = function (web3, from, to, value, client, callback) { | ||
var deposit = function (eth, from, to, value, client, callback) { | ||
var abi = exchangeAbi; | ||
return web3.eth.contract(abi).at(to).deposit(client, { | ||
return eth.contract(abi).at(to).deposit(client, { | ||
from: from, | ||
@@ -91,0 +91,0 @@ value: value |
/* jshint ignore:start */ | ||
Package.describe({ | ||
name: 'ethereum:web3', | ||
version: '0.14.1', | ||
version: '0.15.0', | ||
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC', | ||
@@ -6,0 +6,0 @@ git: 'https://github.com/ethereum/ethereum.js', |
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
3141604
173
45021
4
2
2