@ -15,52 +15,6 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ
You should have received a copy of the GNU Lesser General Public License
You should have received a copy of the GNU Lesser General Public License
along with ethereum . js . If not , see < http : //www.gnu.org/licenses/>.
along with ethereum . js . If not , see < http : //www.gnu.org/licenses/>.
* /
* /
/ * *
* @ file abi . js
* @ author Marek Kotewicz < marek @ ethdev . com >
* @ author Gav Wood < g @ ethdev . com >
* @ date 2014
* /
var coder = require ( './coder' ) ;
var utils = require ( './utils' ) ;
var formatConstructorParams = function ( abi , params ) {
var constructor = utils . getConstructor ( abi , params . length ) ;
if ( ! constructor ) {
if ( params . length > 0 ) {
console . warn ( "didn't found matching constructor, using default one" ) ;
}
return '' ;
}
return coder . encodeParams ( constructor . inputs . map ( function ( input ) {
return input . type ;
} ) , params ) ;
} ;
module . exports = {
formatConstructorParams : formatConstructorParams
} ;
} , { "./coder" : 2 , "./utils" : 5 } ] , 2 : [ function ( require , module , exports ) {
/ *
This file is part of ethereum . js .
ethereum . js is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
ethereum . js is distributed in the hope that it will be useful ,
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 ethereum . js . If not , see < http : //www.gnu.org/licenses/>.
* /
/ * *
/ * *
* @ file coder . js
* @ file coder . js
* @ author Marek Kotewicz < marek @ ethdev . com >
* @ author Marek Kotewicz < marek @ ethdev . com >
@ -328,7 +282,7 @@ var coder = new SolidityCoder([
module . exports = coder ;
module . exports = coder ;
} , { "../utils/utils" : 8 , "./formatters" : 3 , "./param" : 4 , "bignumber.js" : "bignumber.js" } ] , 3 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 , "./formatters" : 2 , "./param" : 3 , "bignumber.js" : "bignumber.js" } ] , 2 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -548,7 +502,7 @@ module.exports = {
} ;
} ;
} , { "../utils/config" : 7 , "../utils/utils" : 8 , "./param" : 4 , "bignumber.js" : "bignumber.js" } ] , 4 : [ function ( require , module , exports ) {
} , { "../utils/config" : 5 , "../utils/utils" : 6 , "./param" : 3 , "bignumber.js" : "bignumber.js" } ] , 3 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -760,54 +714,7 @@ SolidityParam.decodeArray = function (bytes, index) {
module . exports = SolidityParam ;
module . exports = SolidityParam ;
} , { "../utils/utils" : 8 } ] , 5 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 } ] , 4 : [ function ( require , module , exports ) {
/ *
This file is part of ethereum . js .
ethereum . js is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
ethereum . js is distributed in the hope that it will be useful ,
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 ethereum . js . If not , see < http : //www.gnu.org/licenses/>.
* /
/ * *
* @ file utils . js
* @ author Marek Kotewicz < marek @ ethdev . com >
* @ date 2015
* /
/ * *
* Returns the contstructor with matching number of arguments
*
* @ method getConstructor
* @ param { Array } abi
* @ param { Number } numberOfArgs
* @ returns { Object } constructor function abi
* /
var getConstructor = function ( abi , numberOfArgs ) {
return abi . filter ( function ( f ) {
return f . type === 'constructor' && f . inputs . length === numberOfArgs ;
} ) [ 0 ] ;
} ;
//var getSupremeType = function (type) {
//return type.substr(0, type.indexOf('[')) + ']';
//};
module . exports = {
getConstructor : getConstructor
} ;
} , { } ] , 6 : [ function ( require , module , exports ) {
'use strict' ;
'use strict' ;
// go env doesn't have and need XMLHttpRequest
// go env doesn't have and need XMLHttpRequest
@ -818,7 +725,7 @@ if (typeof XMLHttpRequest === 'undefined') {
}
}
} , { } ] , 7 : [ function ( require , module , exports ) {
} , { } ] , 5 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -890,7 +797,7 @@ module.exports = {
} ;
} ;
} , { "bignumber.js" : "bignumber.js" } ] , 8 : [ function ( require , module , exports ) {
} , { "bignumber.js" : "bignumber.js" } ] , 6 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1256,6 +1163,7 @@ var toAddress = function (address) {
return '0x' + padLeft ( toHex ( address ) . substr ( 2 ) , 40 ) ;
return '0x' + padLeft ( toHex ( address ) . substr ( 2 ) , 40 ) ;
} ;
} ;
/ * *
/ * *
* Returns true if object is BigNumber , otherwise false
* Returns true if object is BigNumber , otherwise false
*
*
@ -1366,12 +1274,12 @@ module.exports = {
} ;
} ;
} , { "bignumber.js" : "bignumber.js" } ] , 9 : [ function ( require , module , exports ) {
} , { "bignumber.js" : "bignumber.js" } ] , 7 : [ function ( require , module , exports ) {
module . exports = {
module . exports = {
"version" : "0.3.6 "
"version" : "0.4.2 "
}
}
} , { } ] , 10 : [ function ( require , module , exports ) {
} , { } ] , 8 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1411,6 +1319,7 @@ var RequestManager = require('./web3/requestmanager');
var c = require ( './utils/config' ) ;
var c = require ( './utils/config' ) ;
var Method = require ( './web3/method' ) ;
var Method = require ( './web3/method' ) ;
var Property = require ( './web3/property' ) ;
var Property = require ( './web3/property' ) ;
var Batch = require ( './web3/batch' ) ;
var web3Methods = [
var web3Methods = [
new Method ( {
new Method ( {
@ -1503,6 +1412,9 @@ web3.toBigNumber = utils.toBigNumber;
web3 . toWei = utils . toWei ;
web3 . toWei = utils . toWei ;
web3 . fromWei = utils . fromWei ;
web3 . fromWei = utils . fromWei ;
web3 . isAddress = utils . isAddress ;
web3 . isAddress = utils . isAddress ;
web3 . createBatch = function ( ) {
return new Batch ( ) ;
} ;
// ADD defaultblock
// ADD defaultblock
Object . defineProperty ( web3 . eth , 'defaultBlock' , {
Object . defineProperty ( web3 . eth , 'defaultBlock' , {
@ -1538,7 +1450,70 @@ setupMethods(web3.shh, shh.methods);
module . exports = web3 ;
module . exports = web3 ;
} , { "./utils/config" : 7 , "./utils/utils" : 8 , "./version.json" : 9 , "./web3/db" : 12 , "./web3/eth" : 14 , "./web3/filter" : 16 , "./web3/formatters" : 17 , "./web3/method" : 21 , "./web3/net" : 22 , "./web3/property" : 23 , "./web3/requestmanager" : 25 , "./web3/shh" : 26 , "./web3/watches" : 27 } ] , 11 : [ function ( require , module , exports ) {
} , { "./utils/config" : 5 , "./utils/utils" : 6 , "./version.json" : 7 , "./web3/batch" : 9 , "./web3/db" : 11 , "./web3/eth" : 13 , "./web3/filter" : 15 , "./web3/formatters" : 16 , "./web3/method" : 20 , "./web3/net" : 21 , "./web3/property" : 22 , "./web3/requestmanager" : 24 , "./web3/shh" : 25 , "./web3/watches" : 26 } ] , 9 : [ function ( require , module , exports ) {
/ *
This file is part of ethereum . js .
ethereum . js is free software : you can redistribute it and / or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
ethereum . js is distributed in the hope that it will be useful ,
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 ethereum . js . If not , see < http : //www.gnu.org/licenses/>.
* /
/ * *
* @ file batch . js
* @ author Marek Kotewicz < marek @ ethdev . com >
* @ date 2015
* /
var RequestManager = require ( './requestmanager' ) ;
var Batch = function ( ) {
this . requests = [ ] ;
} ;
/ * *
* Should be called to add create new request to batch request
*
* @ method add
* @ param { Object } jsonrpc requet object
* /
Batch . prototype . add = function ( request ) {
this . requests . push ( request ) ;
} ;
/ * *
* Should be called to execute batch request
*
* @ method execute
* /
Batch . prototype . execute = function ( ) {
var requests = this . requests ;
RequestManager . getInstance ( ) . sendBatch ( requests , function ( err , results ) {
results = results || [ ] ;
requests . map ( function ( request , index ) {
return results [ index ] || { } ;
} ) . map ( function ( result , index ) {
return requests [ index ] . format ? requests [ index ] . format ( result . result ) : result . result ;
} ) . forEach ( function ( result , index ) {
if ( requests [ index ] . callback ) {
requests [ index ] . callback ( err , result ) ;
}
} ) ;
} ) ;
} ;
module . exports = Batch ;
} , { "./requestmanager" : 24 } ] , 10 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1562,13 +1537,39 @@ module.exports = web3;
* /
* /
var web3 = require ( '../web3' ) ;
var web3 = require ( '../web3' ) ;
var solAbi = require ( '../solidity/abi' ) ;
var utils = require ( '../utils/utils' ) ;
var utils = require ( '../utils/utils' ) ;
var coder = require ( '../solidity/coder' ) ;
var SolidityEvent = require ( './event' ) ;
var SolidityEvent = require ( './event' ) ;
var SolidityFunction = require ( './function' ) ;
var SolidityFunction = require ( './function' ) ;
var addFunctionsToContract = function ( contract , desc ) {
/ * *
desc . filter ( function ( json ) {
* Should be called to encode constructor params
*
* @ method encodeConstructorParams
* @ param { Array } abi
* @ param { Array } constructor params
* /
var encodeConstructorParams = function ( abi , params ) {
return abi . filter ( function ( json ) {
return json . type === 'constructor' && json . inputs . length === params . length ;
} ) . map ( function ( json ) {
return json . inputs . map ( function ( input ) {
return input . type ;
} ) ;
} ) . map ( function ( types ) {
return coder . encodeParams ( types , params ) ;
} ) [ 0 ] || '' ;
} ;
/ * *
* Should be called to add functions to contract object
*
* @ method addFunctionsToContract
* @ param { Contract } contract
* @ param { Array } abi
* /
var addFunctionsToContract = function ( contract , abi ) {
abi . filter ( function ( json ) {
return json . type === 'function' ;
return json . type === 'function' ;
} ) . map ( function ( json ) {
} ) . map ( function ( json ) {
return new SolidityFunction ( json , contract . address ) ;
return new SolidityFunction ( json , contract . address ) ;
@ -1577,8 +1578,15 @@ var addFunctionsToContract = function (contract, desc) {
} ) ;
} ) ;
} ;
} ;
var addEventsToContract = function ( contract , desc ) {
/ * *
desc . filter ( function ( json ) {
* Should be called to add events to contract object
*
* @ method addEventsToContract
* @ param { Contract } contract
* @ param { Array } abi
* /
var addEventsToContract = function ( contract , abi ) {
abi . filter ( function ( json ) {
return json . type === 'event' ;
return json . type === 'event' ;
} ) . map ( function ( json ) {
} ) . map ( function ( json ) {
return new SolidityEvent ( json , contract . address ) ;
return new SolidityEvent ( json , contract . address ) ;
@ -1588,65 +1596,106 @@ var addEventsToContract = function (contract, desc) {
} ;
} ;
/ * *
/ * *
* This method should be called when we want to call / transact some solidity method from javascript
* Should be called to create new ContractFactory
* it returns an object which has same methods available as solidity contract description
* usage example :
*
* var abi = [ {
* name : 'myMethod' ,
* inputs : [ { name : 'a' , type : 'string' } ] ,
* outputs : [ { name : 'd' , type : 'string' } ]
* } ] ; // contract abi
*
*
* var MyContract = web3 . eth . contract ( abi ) ; // creation of contract prototype
* @ method contract
*
* @ param { Array } abi
* var contractInstance = new MyContract ( '0x0123123121' ) ;
* @ returns { ContractFactory } new contract factory
*
* contractInstance . myMethod ( 'this is test string param for call' ) ; // myMethod call (implicit, default)
* contractInstance . call ( ) . myMethod ( 'this is test string param for call' ) ; // myMethod call (explicit)
* contractInstance . sendTransaction ( ) . myMethod ( 'this is test string param for transact' ) ; // myMethod sendTransaction
*
* @ param abi - abi json description of the contract , which is being created
* @ returns contract object
* /
* /
var contract = function ( abi ) {
var contract = function ( abi ) {
return new ContractFactory ( abi ) ;
} ;
// return prototype
/ * *
return Contract . bind ( null , abi ) ;
* Should be called to create new ContractFactory instance
*
* @ method ContractFactory
* @ param { Array } abi
* /
var ContractFactory = function ( abi ) {
this . abi = abi ;
} ;
} ;
var Contract = function ( abi , options ) {
/ * *
* Should be called to create new contract on a blockchain
*
* @ method new
* @ param { Any } contract constructor param1 ( optional )
* @ param { Any } contract constructor param2 ( optional )
* @ param { Object } contract transaction object ( required )
* @ param { Function } callback
* @ returns { Contract } returns contract if no callback was passed ,
* otherwise calls callback function ( err , contract )
* /
ContractFactory . prototype . new = function ( ) {
// parse arguments
var options = { } ; // required!
var callback ;
this . address = '' ;
var args = Array . prototype . slice . call ( arguments ) ;
if ( utils . isAddress ( options ) ) {
if ( utils . isFunction ( args [ args . length - 1 ] ) ) {
this . address = options ;
callback = args . pop ( ) ;
} else { // is an object!
}
// TODO, parse the rest of the args
options = options || { } ;
var last = args [ args . length - 1 ] ;
var args = Array . prototype . slice . call ( arguments , 2 ) ;
if ( utils . isObject ( last ) && ! utils . isArray ( last ) ) {
var bytes = solAbi . formatConstructorParams ( abi , args ) ;
options = args . pop ( ) ;
}
// throw an error if there are no options
var bytes = encodeConstructorParams ( this . abi , args ) ;
options . data += bytes ;
options . data += bytes ;
this . address = web3 . eth . sendTransaction ( options ) ;
if ( ! callback ) {
var address = web3 . eth . sendTransaction ( options ) ;
return this . at ( address ) ;
}
}
addFunctionsToContract ( this , abi ) ;
var self = this ;
addEventsToContract ( this , abi ) ;
web3 . eth . sendTransaction ( options , function ( err , address ) {
if ( err ) {
callback ( err ) ;
}
self . at ( address , callback ) ;
} ) ;
} ;
} ;
Contract . prototype . call = function ( ) {
/ * *
console . error ( 'contract.call is deprecated' ) ;
* Should be called to get access to existing contract on a blockchain
return this ;
*
* @ method at
* @ param { Address } contract address ( required )
* @ param { Function } callback { optional )
* @ returns { Contract } returns contract if no callback was passed ,
* otherwise calls callback function ( err , contract )
* /
ContractFactory . prototype . at = function ( address , callback ) {
// TODO: address is required
if ( callback ) {
callback ( null , new Contract ( this . abi , address ) ) ;
}
return new Contract ( this . abi , address ) ;
} ;
} ;
Contract . prototype . sendTransaction = function ( ) {
/ * *
console . error ( 'contract.sendTransact is deprecated' ) ;
* Should be called to create new contract instance
return this ;
*
* @ method Contract
* @ param { Array } abi
* @ param { Address } contract address
* /
var Contract = function ( abi , address ) {
this . address = address ;
addFunctionsToContract ( this , abi ) ;
addEventsToContract ( this , abi ) ;
} ;
} ;
module . exports = contract ;
module . exports = contract ;
} , { "../solidity/abi" : 1 , "../utils/utils" : 8 , "../web3" : 10 , "./event" : 15 , "./function" : 18 } ] , 12 : [ function ( require , module , exports ) {
} , { "../solidity/coder " : 1 , "../utils/utils" : 6 , "../web3" : 8 , "./event" : 14 , "./function" : 17 } ] , 11 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1704,7 +1753,7 @@ module.exports = {
methods : methods
methods : methods
} ;
} ;
} , { "./method" : 21 } ] , 13 : [ function ( require , module , exports ) {
} , { "./method" : 20 } ] , 12 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1744,7 +1793,7 @@ module.exports = {
} ;
} ;
} , { } ] , 14 : [ function ( require , module , exports ) {
} , { } ] , 13 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1921,6 +1970,14 @@ var call = new Method({
inputFormatter : [ formatters . inputTransactionFormatter , formatters . inputDefaultBlockNumberFormatter ]
inputFormatter : [ formatters . inputTransactionFormatter , formatters . inputDefaultBlockNumberFormatter ]
} ) ;
} ) ;
var estimateGas = new Method ( {
name : 'estimateGas' ,
call : 'eth_estimateGas' ,
params : 1 ,
inputFormatter : [ formatters . inputTransactionFormatter ] ,
outputFormatter : utils . toDecimal
} ) ;
var compileSolidity = new Method ( {
var compileSolidity = new Method ( {
name : 'compile.solidity' ,
name : 'compile.solidity' ,
call : 'eth_compileSolidity' ,
call : 'eth_compileSolidity' ,
@ -1939,6 +1996,18 @@ var compileSerpent = new Method({
params : 1
params : 1
} ) ;
} ) ;
var submitWork = new Method ( {
name : 'submitWork' ,
call : 'eth_submitWork' ,
params : 3
} ) ;
var getWork = new Method ( {
name : 'getWork' ,
call : 'eth_getWork' ,
params : 0
} ) ;
var methods = [
var methods = [
getBalance ,
getBalance ,
getStorageAt ,
getStorageAt ,
@ -1952,10 +2021,13 @@ var methods = [
getTransactionFromBlock ,
getTransactionFromBlock ,
getTransactionCount ,
getTransactionCount ,
call ,
call ,
estimateGas ,
sendTransaction ,
sendTransaction ,
compileSolidity ,
compileSolidity ,
compileLLL ,
compileLLL ,
compileSerpent ,
compileSerpent ,
submitWork ,
getWork
] ;
] ;
/// @returns an array of objects describing web3.eth api properties
/// @returns an array of objects describing web3.eth api properties
@ -1998,7 +2070,7 @@ module.exports = {
} ;
} ;
} , { "../utils/utils" : 8 , "./formatters" : 17 , "./method" : 21 , "./property" : 23 } ] , 15 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 , "./formatters" : 16 , "./method" : 20 , "./property" : 22 } ] , 14 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2194,7 +2266,7 @@ SolidityEvent.prototype.attachToContract = function (contract) {
module . exports = SolidityEvent ;
module . exports = SolidityEvent ;
} , { "../solidity/coder" : 2 , "../utils/utils" : 8 , "../web3" : 10 , "./formatters" : 17 } ] , 16 : [ function ( require , module , exports ) {
} , { "../solidity/coder" : 1 , "../utils/utils" : 6 , "../web3" : 8 , "./formatters" : 16 } ] , 15 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2351,7 +2423,7 @@ Filter.prototype.get = function (callback) {
module . exports = Filter ;
module . exports = Filter ;
} , { "../utils/utils" : 8 , "./formatters" : 17 , "./requestmanager" : 25 } ] , 17 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 , "./formatters" : 16 , "./requestmanager" : 24 } ] , 16 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2571,7 +2643,7 @@ module.exports = {
} ;
} ;
} , { "../utils/config" : 7 , "../utils/utils" : 8 } ] , 18 : [ function ( require , module , exports ) {
} , { "../utils/config" : 5 , "../utils/utils" : 6 } ] , 17 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2613,18 +2685,23 @@ var SolidityFunction = function (json, address) {
this . _ address = address ;
this . _ address = address ;
} ;
} ;
SolidityFunction . prototype . extractCallback = function ( args ) {
if ( utils . isFunction ( args [ args . length - 1 ] ) ) {
return args . pop ( ) ; // modify the args array!
}
} ;
/ * *
/ * *
* Should be used to create payload from arguments
* Should be used to create payload from arguments
*
*
* @ method toPayload
* @ method toPayload
* @ param { ... } solidity function params
* @ param { Array } solidity function params
* @ param { Object } optional payload options
* @ param { Object } optional payload options
* /
* /
SolidityFunction . prototype . toPayload = function ( ) {
SolidityFunction . prototype . toPayload = function ( args ) {
var args = Array . prototype . slice . call ( arguments ) ;
var options = { } ;
var options = { } ;
if ( args . length > this . _ inputTypes . length && utils . isObject ( args [ args . length - 1 ] ) ) {
if ( args . length > this . _ inputTypes . length && utils . isObject ( args [ args . length - 1 ] ) ) {
options = args . pop ( ) ;
options = args [ args . length - 1 ] ;
}
}
options . to = this . _ address ;
options . to = this . _ address ;
options . data = '0x' + this . signature ( ) + coder . encodeParams ( this . _ inputTypes , args ) ;
options . data = '0x' + this . signature ( ) + coder . encodeParams ( this . _ inputTypes , args ) ;
@ -2641,19 +2718,41 @@ SolidityFunction.prototype.signature = function () {
return web3 . sha3 ( web3 . fromAscii ( this . _ name ) ) . slice ( 2 , 10 ) ;
return web3 . sha3 ( web3 . fromAscii ( this . _ name ) ) . slice ( 2 , 10 ) ;
} ;
} ;
SolidityFunction . prototype . unpackOutput = function ( output ) {
if ( output === null ) {
return ;
}
output = output . length >= 2 ? output . slice ( 2 ) : output ;
var result = coder . decodeParams ( this . _ outputTypes , output ) ;
return result . length === 1 ? result [ 0 ] : result ;
} ;
/ * *
/ * *
* Should be used to call function
* Calls a contract function .
*
*
* @ method call
* @ method call
* @ param { Object } options
* @ param { ... Object } Contract function arguments
* @ param { function } If the last argument is a function , the contract function
* call will be asynchronous , and the callback will be passed the
* error and result .
* @ return { String } output bytes
* @ return { String } output bytes
* /
* /
SolidityFunction . prototype . call = function ( ) {
SolidityFunction . prototype . call = function ( ) {
var payload = this . toPayload . apply ( this , Array . prototype . slice . call ( arguments ) ) ;
var args = Array . prototype . slice . call ( arguments ) ;
var callback = this . extractCallback ( args ) ;
var payload = this . toPayload ( args ) ;
if ( ! callback ) {
var output = web3 . eth . call ( payload ) ;
var output = web3 . eth . call ( payload ) ;
output = output . length >= 2 ? output . slice ( 2 ) : output ;
return this . unpackOutput ( output ) ;
var result = coder . decodeParams ( this . _ outputTypes , output ) ;
}
return result . length === 1 ? result [ 0 ] : result ;
var self = this ;
web3 . eth . call ( payload , function ( error , output ) {
callback ( error , self . unpackOutput ( output ) ) ;
} ) ;
} ;
} ;
/ * *
/ * *
@ -2663,8 +2762,16 @@ SolidityFunction.prototype.call = function () {
* @ param { Object } options
* @ param { Object } options
* /
* /
SolidityFunction . prototype . sendTransaction = function ( ) {
SolidityFunction . prototype . sendTransaction = function ( ) {
var payload = this . toPayload . apply ( this , Array . prototype . slice . call ( arguments ) ) ;
var args = Array . prototype . slice . call ( arguments ) ;
var callback = this . extractCallback ( args ) ;
var payload = this . toPayload ( args ) ;
if ( ! callback ) {
web3 . eth . sendTransaction ( payload ) ;
web3 . eth . sendTransaction ( payload ) ;
return ;
}
web3 . eth . sendTransaction ( payload , callback ) ;
} ;
} ;
/ * *
/ * *
@ -2687,6 +2794,25 @@ SolidityFunction.prototype.typeName = function () {
return utils . extractTypeName ( this . _ name ) ;
return utils . extractTypeName ( this . _ name ) ;
} ;
} ;
/ * *
* Should be called to get rpc requests from solidity function
*
* @ method request
* @ returns { Object }
* /
SolidityFunction . prototype . request = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
var callback = this . extractCallback ( args ) ;
var payload = this . toPayload ( args ) ;
var format = this . unpackOutput . bind ( this ) ;
return {
callback : callback ,
payload : payload ,
format : format
} ;
} ;
/ * *
/ * *
* Should be called to execute function
* Should be called to execute function
*
*
@ -2712,6 +2838,7 @@ SolidityFunction.prototype.execute = function () {
* /
* /
SolidityFunction . prototype . attachToContract = function ( contract ) {
SolidityFunction . prototype . attachToContract = function ( contract ) {
var execute = this . execute . bind ( this ) ;
var execute = this . execute . bind ( this ) ;
execute . request = this . request . bind ( this ) ;
execute . call = this . call . bind ( this ) ;
execute . call = this . call . bind ( this ) ;
execute . sendTransaction = this . sendTransaction . bind ( this ) ;
execute . sendTransaction = this . sendTransaction . bind ( this ) ;
var displayName = this . displayName ( ) ;
var displayName = this . displayName ( ) ;
@ -2724,7 +2851,7 @@ SolidityFunction.prototype.attachToContract = function (contract) {
module . exports = SolidityFunction ;
module . exports = SolidityFunction ;
} , { "../solidity/coder" : 2 , "../utils/utils" : 8 , "../web3" : 10 } ] , 19 : [ function ( require , module , exports ) {
} , { "../solidity/coder" : 1 , "../utils/utils" : 6 , "../web3" : 8 } ] , 18 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2816,7 +2943,7 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
module . exports = HttpProvider ;
module . exports = HttpProvider ;
} , { "./errors" : 13 , "xmlhttprequest" : 6 } ] , 20 : [ function ( require , module , exports ) {
} , { "./errors" : 12 , "xmlhttprequest" : 4 } ] , 19 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2909,7 +3036,7 @@ Jsonrpc.prototype.toBatchPayload = function (messages) {
module . exports = Jsonrpc ;
module . exports = Jsonrpc ;
} , { } ] , 21 : [ function ( require , module , exports ) {
} , { } ] , 20 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -2966,7 +3093,6 @@ Method.prototype.extractCallback = function (args) {
if ( utils . isFunction ( args [ args . length - 1 ] ) ) {
if ( utils . isFunction ( args [ args . length - 1 ] ) ) {
return args . pop ( ) ; // modify the args array!
return args . pop ( ) ; // modify the args array!
}
}
return null ;
} ;
} ;
/ * *
/ * *
@ -3019,6 +3145,7 @@ Method.prototype.formatOutput = function (result) {
* /
* /
Method . prototype . attachToObject = function ( obj ) {
Method . prototype . attachToObject = function ( obj ) {
var func = this . send . bind ( this ) ;
var func = this . send . bind ( this ) ;
func . request = this . request . bind ( this ) ;
func . call = this . call ; // that's ugly. filter.js uses it
func . call = this . call ; // that's ugly. filter.js uses it
var name = this . name . split ( '.' ) ;
var name = this . name . split ( '.' ) ;
if ( name . length > 1 ) {
if ( name . length > 1 ) {
@ -3049,6 +3176,19 @@ Method.prototype.toPayload = function (args) {
} ;
} ;
} ;
} ;
/ * *
* Should be called to create pure JSONRPC request which can be used in batch request
*
* @ method request
* @ param { ... } params
* @ return { Object } jsonrpc request
* /
Method . prototype . request = function ( ) {
var payload = this . toPayload ( Array . prototype . slice . call ( arguments ) ) ;
payload . format = this . formatOutput . bind ( this ) ;
return payload ;
} ;
/ * *
/ * *
* Should send request to the API
* Should send request to the API
*
*
@ -3061,7 +3201,7 @@ Method.prototype.send = function () {
if ( payload . callback ) {
if ( payload . callback ) {
var self = this ;
var self = this ;
return RequestManager . getInstance ( ) . sendAsync ( payload , function ( err , result ) {
return RequestManager . getInstance ( ) . sendAsync ( payload , function ( err , result ) {
payload . callback ( null , self . formatOutput ( result ) ) ;
payload . callback ( err , self . formatOutput ( result ) ) ;
} ) ;
} ) ;
}
}
return this . formatOutput ( RequestManager . getInstance ( ) . send ( payload ) ) ;
return this . formatOutput ( RequestManager . getInstance ( ) . send ( payload ) ) ;
@ -3070,7 +3210,7 @@ Method.prototype.send = function () {
module . exports = Method ;
module . exports = Method ;
} , { "../utils/utils" : 8 , "./errors" : 13 , "./requestmanager" : 25 } ] , 22 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 , "./errors" : 12 , "./requestmanager" : 24 } ] , 21 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3120,7 +3260,7 @@ module.exports = {
} ;
} ;
} , { "../utils/utils" : 8 , "./property" : 23 } ] , 23 : [ function ( require , module , exports ) {
} , { "../utils/utils" : 6 , "./property" : 22 } ] , 22 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3186,16 +3326,23 @@ Property.prototype.formatOutput = function (result) {
Property . prototype . attachToObject = function ( obj ) {
Property . prototype . attachToObject = function ( obj ) {
var proto = {
var proto = {
get : this . get . bind ( this ) ,
get : this . get . bind ( this ) ,
set : this . set . bind ( this )
} ;
} ;
var name = this . name . split ( '.' ) ;
var names = this . name . split ( '.' ) ;
if ( name . length > 1 ) {
var name = names [ 0 ] ;
obj [ name [ 0 ] ] = obj [ name [ 0 ] ] || { } ;
if ( names . length > 1 ) {
Object . defineProperty ( obj [ name [ 0 ] ] , name [ 1 ] , proto ) ;
obj [ names [ 0 ] ] = obj [ names [ 0 ] ] || { } ;
} else {
obj = obj [ names [ 0 ] ] ;
Object . defineProperty ( obj , name [ 0 ] , proto ) ;
name = names [ 1 ] ;
}
}
Object . defineProperty ( obj , name , proto ) ;
var toAsyncName = function ( prefix , name ) {
return prefix + name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) ;
} ;
obj [ toAsyncName ( 'get' , name ) ] = this . getAsync . bind ( this ) ;
} ;
} ;
/ * *
/ * *
@ -3211,22 +3358,27 @@ Property.prototype.get = function () {
} ;
} ;
/ * *
/ * *
* Should be used to set value of the property
* Should be used to a synchrounously g et value of property
*
*
* @ method set
* @ method getAsync
* @ param { Object } new value of the property
* @ param { Function }
* /
* /
Property . prototype . set = function ( value ) {
Property . prototype . getAsync = function ( callback ) {
return RequestManager . getInstance ( ) . send ( {
var self = this ;
method : this . setter ,
RequestManager . getInstance ( ) . sendAsync ( {
params : [ this . formatInput ( value ) ]
method : this . getter
} , function ( err , result ) {
if ( err ) {
return callback ( err ) ;
}
callback ( err , self . formatOutput ( result ) ) ;
} ) ;
} ) ;
} ;
} ;
module . exports = Property ;
module . exports = Property ;
} , { "./requestmanager" : 25 } ] , 24 : [ function ( require , module , exports ) {
} , { "./requestmanager" : 24 } ] , 23 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3261,7 +3413,7 @@ QtSyncProvider.prototype.send = function (payload) {
module . exports = QtSyncProvider ;
module . exports = QtSyncProvider ;
} , { } ] , 25 : [ function ( require , module , exports ) {
} , { } ] , 24 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3369,6 +3521,33 @@ RequestManager.prototype.sendAsync = function (data, callback) {
} ) ;
} ) ;
} ;
} ;
/ * *
* Should be called to asynchronously send batch request
*
* @ method sendBatch
* @ param { Array } batch data
* @ param { Function } callback
* /
RequestManager . prototype . sendBatch = function ( data , callback ) {
if ( ! this . provider ) {
return callback ( errors . InvalidProvider ( ) ) ;
}
var payload = Jsonrpc . getInstance ( ) . toBatchPayload ( data ) ;
this . provider . sendAsync ( payload , function ( err , results ) {
if ( err ) {
return callback ( err ) ;
}
if ( ! utils . isArray ( results ) ) {
return callback ( errors . InvalidResponse ( results ) ) ;
}
callback ( err , results ) ;
} ) ;
} ;
/ * *
/ * *
* Should be used to set provider of request manager
* Should be used to set provider of request manager
*
*
@ -3482,7 +3661,7 @@ RequestManager.prototype.poll = function () {
module . exports = RequestManager ;
module . exports = RequestManager ;
} , { "../utils/config" : 7 , "../utils/utils" : 8 , "./errors" : 13 , "./jsonrpc" : 20 } ] , 26 : [ function ( require , module , exports ) {
} , { "../utils/config" : 5 , "../utils/utils" : 6 , "./errors" : 12 , "./jsonrpc" : 19 } ] , 25 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3552,7 +3731,7 @@ module.exports = {
} ;
} ;
} , { "./formatters" : 17 , "./method" : 21 } ] , 27 : [ function ( require , module , exports ) {
} , { "./formatters" : 16 , "./method" : 20 } ] , 26 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -3580,7 +3759,20 @@ var Method = require('./method');
/// @returns an array of objects describing web3.eth.filter api methods
/// @returns an array of objects describing web3.eth.filter api methods
var eth = function ( ) {
var eth = function ( ) {
var newFilterCall = function ( args ) {
var newFilterCall = function ( args ) {
return typeof args [ 0 ] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter' ;
var type = args [ 0 ] ;
switch ( type ) {
case 'latest' :
args . pop ( ) ;
this . params = 0 ;
return 'eth_newBlockFilter' ;
case 'pending' :
args . pop ( ) ;
this . params = 0 ;
return 'eth_newPendingTransactionFilter' ;
default :
return 'eth_newFilter' ;
}
} ;
} ;
var newFilter = new Method ( {
var newFilter = new Method ( {
@ -3655,7 +3847,7 @@ module.exports = {
} ;
} ;
} , { "./method" : 21 } ] , 28 : [ function ( require , module , exports ) {
} , { "./method" : 20 } ] , 27 : [ function ( require , module , exports ) {
} , { } ] , "bignumber.js" : [ function ( require , module , exports ) {
} , { } ] , "bignumber.js" : [ function ( require , module , exports ) {
/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
@ -6342,12 +6534,11 @@ module.exports = {
}
}
} ) ( this ) ;
} ) ( this ) ;
} , { "crypto" : 28 } ] , "web3" : [ function ( require , module , exports ) {
} , { "crypto" : 27 } ] , "web3" : [ function ( require , module , exports ) {
var web3 = require ( './lib/web3' ) ;
var web3 = require ( './lib/web3' ) ;
web3 . providers . HttpProvider = require ( './lib/web3/httpprovider' ) ;
web3 . providers . HttpProvider = require ( './lib/web3/httpprovider' ) ;
web3 . providers . QtSyncProvider = require ( './lib/web3/qtsync' ) ;
web3 . providers . QtSyncProvider = require ( './lib/web3/qtsync' ) ;
web3 . eth . contract = require ( './lib/web3/contract' ) ;
web3 . eth . contract = require ( './lib/web3/contract' ) ;
web3 . abi = require ( './lib/solidity/abi' ) ;
// dont override global variable
// dont override global variable
if ( typeof window !== 'undefined' && typeof window . web3 === 'undefined' ) {
if ( typeof window !== 'undefined' && typeof window . web3 === 'undefined' ) {
@ -6357,7 +6548,7 @@ if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
module . exports = web3 ;
module . exports = web3 ;
} , { "./lib/solidity/abi" : 1 , "./lib/ web3" : 10 , "./lib/web3/contract" : 11 , "./lib/web3/httpprovider" : 19 , "./lib/web3/qtsync" : 24 } ] } , { } , [ "web3" ] )
} , { "./lib/web3" : 8 , "./lib/web3/contract" : 10 , "./lib/web3/httpprovider" : 18 , "./lib/web3/qtsync" : 23 } ] } , { } , [ "web3" ] )
//# sourceMappingURL=web3.js.map
//# sourceMappingURL=web3.js.map