@ -53,7 +53,6 @@ var inputTypes = types.inputTypes();
/// @returns bytes representation of input params
/// @returns bytes representation of input params
var formatInput = function ( inputs , params ) {
var formatInput = function ( inputs , params ) {
var bytes = "" ;
var bytes = "" ;
var padding = c . ETH _PADDING * 2 ;
/// first we iterate in search for dynamic
/// first we iterate in search for dynamic
inputs . forEach ( function ( input , index ) {
inputs . forEach ( function ( input , index ) {
@ -110,6 +109,7 @@ var formatOutput = function (outs, output) {
output = output . slice ( dynamicPartLength ) ;
output = output . slice ( dynamicPartLength ) ;
outs . forEach ( function ( out , i ) {
outs . forEach ( function ( out , i ) {
/*jshint maxcomplexity:6 */
var typeMatch = false ;
var typeMatch = false ;
for ( var j = 0 ; j < outputTypes . length && ! typeMatch ; j ++ ) {
for ( var j = 0 ; j < outputTypes . length && ! typeMatch ; j ++ ) {
typeMatch = outputTypes [ j ] . type ( outs [ i ] . type ) ;
typeMatch = outputTypes [ j ] . type ( outs [ i ] . type ) ;
@ -210,7 +210,7 @@ module.exports = {
} ;
} ;
} , { "./const" : 2 , "./formatters" : 6 , "./types" : 11 , "./utils" : 12 , "./web3" : 13 } ] , 2 : [ function ( require , module , exports ) {
} , { "./const" : 2 , "./formatters" : 8 , "./types" : 14 , "./utils" : 15 , "./web3" : 17 } ] , 2 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -264,7 +264,8 @@ module.exports = {
ETH _PADDING : 32 ,
ETH _PADDING : 32 ,
ETH _SIGNATURE _LENGTH : 4 ,
ETH _SIGNATURE _LENGTH : 4 ,
ETH _UNITS : ETH _UNITS ,
ETH _UNITS : ETH _UNITS ,
ETH _BIGNUMBER _ROUNDING _MODE : { ROUNDING _MODE : BigNumber . ROUND _DOWN }
ETH _BIGNUMBER _ROUNDING _MODE : { ROUNDING _MODE : BigNumber . ROUND _DOWN } ,
ETH _POLLING _TIMEOUT : 1000
} ;
} ;
@ -340,6 +341,7 @@ var addFunctionsToContract = function (contract, desc, address) {
var typeName = utils . extractTypeName ( method . name ) ;
var typeName = utils . extractTypeName ( method . name ) ;
var impl = function ( ) {
var impl = function ( ) {
/*jshint maxcomplexity:7 */
var params = Array . prototype . slice . call ( arguments ) ;
var params = Array . prototype . slice . call ( arguments ) ;
var signature = abi . signatureFromAscii ( method . name ) ;
var signature = abi . signatureFromAscii ( method . name ) ;
var parsed = inputParser [ displayName ] [ typeName ] . apply ( null , params ) ;
var parsed = inputParser [ displayName ] [ typeName ] . apply ( null , params ) ;
@ -416,11 +418,11 @@ var addEventsToContract = function (contract, desc, address) {
var signature = abi . eventSignatureFromAscii ( e . name ) ;
var signature = abi . eventSignatureFromAscii ( e . name ) ;
var event = eventImpl . inputParser ( address , signature , e ) ;
var event = eventImpl . inputParser ( address , signature , e ) ;
var o = event . apply ( null , params ) ;
var o = event . apply ( null , params ) ;
o . _onWatchEventResult = function ( data ) {
var outputFormatter = function ( data ) {
var parser = eventImpl . outputParser ( e ) ;
var parser = eventImpl . outputParser ( e ) ;
return parser ( data ) ;
return parser ( data ) ;
} ;
} ;
return web3 . eth . watch ( o ) ;
return web3 . eth . watch ( o , undefined , undefined , outputFormatter ) ;
} ;
} ;
// this property should be used by eth.filter to check if object is an event
// this property should be used by eth.filter to check if object is an event
@ -487,7 +489,131 @@ var contract = function (address, desc) {
module . exports = contract ;
module . exports = contract ;
} , { "./abi" : 1 , "./event" : 4 , "./utils" : 12 , "./web3" : 13 } ] , 4 : [ function ( require , module , exports ) {
} , { "./abi" : 1 , "./event" : 6 , "./utils" : 15 , "./web3" : 17 } ] , 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/>.
* /
/ * * @ f i l e d b . j s
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* @ date 2015
* /
/// @returns an array of objects describing web3.db api methods
var methods = function ( ) {
return [
{ name : 'put' , call : 'db_put' } ,
{ name : 'get' , call : 'db_get' } ,
{ name : 'putString' , call : 'db_putString' } ,
{ name : 'getString' , call : 'db_getString' }
] ;
} ;
module . exports = {
methods : methods
} ;
} , { } ] , 5 : [ 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/>.
* /
/ * * @ f i l e e t h . j s
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* @ date 2015
* /
/// @returns an array of objects describing web3.eth api methods
var methods = function ( ) {
var blockCall = function ( args ) {
return typeof args [ 0 ] === "string" ? "eth_blockByHash" : "eth_blockByNumber" ;
} ;
var transactionCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber' ;
} ;
var uncleCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber' ;
} ;
var transactionCountCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_transactionCountByHash' : 'eth_transactionCountByNumber' ;
} ;
var uncleCountCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_uncleCountByHash' : 'eth_uncleCountByNumber' ;
} ;
return [
{ name : 'balanceAt' , call : 'eth_balanceAt' } ,
{ name : 'stateAt' , call : 'eth_stateAt' } ,
{ name : 'storageAt' , call : 'eth_storageAt' } ,
{ name : 'countAt' , call : 'eth_countAt' } ,
{ name : 'codeAt' , call : 'eth_codeAt' } ,
{ name : 'transact' , call : 'eth_transact' } ,
{ name : 'call' , call : 'eth_call' } ,
{ name : 'block' , call : blockCall } ,
{ name : 'transaction' , call : transactionCall } ,
{ name : 'uncle' , call : uncleCall } ,
{ name : 'compilers' , call : 'eth_compilers' } ,
{ name : 'flush' , call : 'eth_flush' } ,
{ name : 'lll' , call : 'eth_lll' } ,
{ name : 'solidity' , call : 'eth_solidity' } ,
{ name : 'serpent' , call : 'eth_serpent' } ,
{ name : 'logs' , call : 'eth_logs' } ,
{ name : 'transactionCount' , call : transactionCountCall } ,
{ name : 'uncleCount' , call : uncleCountCall }
] ;
} ;
/// @returns an array of objects describing web3.eth api properties
var properties = function ( ) {
return [
{ name : 'coinbase' , getter : 'eth_coinbase' , setter : 'eth_setCoinbase' } ,
{ name : 'listening' , getter : 'eth_listening' , setter : 'eth_setListening' } ,
{ name : 'mining' , getter : 'eth_mining' , setter : 'eth_setMining' } ,
{ name : 'gasPrice' , getter : 'eth_gasPrice' } ,
{ name : 'accounts' , getter : 'eth_accounts' } ,
{ name : 'peerCount' , getter : 'eth_peerCount' } ,
{ name : 'defaultBlock' , getter : 'eth_defaultBlock' , setter : 'eth_setDefaultBlock' } ,
{ name : 'number' , getter : 'eth_number' }
] ;
} ;
module . exports = {
methods : methods ,
properties : properties
} ;
} , { } ] , 6 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -571,9 +697,9 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
return inputs . reduce ( function ( acc , current ) {
return inputs . reduce ( function ( acc , current ) {
var value ;
var value ;
if ( current . indexed )
if ( current . indexed )
value = indexed . splice ( 0 , 1 ) [ 0 ] ;
value = indexedCopy . splice ( 0 , 1 ) [ 0 ] ;
else
else
value = notIndexed . splice ( 0 , 1 ) [ 0 ] ;
value = notIndexedCopy . splice ( 0 , 1 ) [ 0 ] ;
acc [ current . name ] = value ;
acc [ current . name ] = value ;
return acc ;
return acc ;
@ -589,6 +715,7 @@ var outputParser = function (event) {
args : { }
args : { }
} ;
} ;
output . topics = output . topic ; // fallback for go-ethereum
if ( ! output . topic ) {
if ( ! output . topic ) {
return result ;
return result ;
}
}
@ -624,7 +751,7 @@ module.exports = {
} ;
} ;
} , { "./abi" : 1 , "./utils" : 12 } ] , 5 : [ function ( require , module , exports ) {
} , { "./abi" : 1 , "./utils" : 15 } ] , 7 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -650,24 +777,33 @@ module.exports = {
* @ date 2014
* @ date 2014
* /
* /
var web3 = require ( './web3' ) ; // jshint ignore:line
/// Should be called to check if filter implementation is valid
/// @returns true if it is, otherwise false
/// should be used when we want to watch something
var implementationIsValid = function ( i ) {
/// it's using inner polling mechanism and is notified about changes
return ! ! i &&
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
typeof i . newFilter === 'function' &&
var Filter = function ( options , impl ) {
typeof i . getMessages === 'function' &&
typeof i . uninstallFilter === 'function' &&
typeof i . startPolling === 'function' &&
typeof i . stopPolling === 'function' ;
} ;
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
/// @param should be string or object
/// @returns options string or object
var getOptions = function ( options ) {
if ( typeof options === 'string' ) {
return options ;
}
if ( typeof options !== "string" ) {
options = options || { } ;
// topics property is deprecated, warn about it!
if ( options . topics ) {
if ( options . topics ) {
console . warn ( '"topics" is deprecated, use "topic" instead' ) ;
console . warn ( '"topics" is deprecated, is "topic" instead' ) ;
}
}
this . _onWatchResult = options . _onWatchEventResult ;
// evaluate lazy properties
// evaluate lazy properties
options = {
return {
to : options . to ,
to : options . to ,
topic : options . topic ,
topic : options . topic ,
earliest : options . earliest ,
earliest : options . earliest ,
@ -676,58 +812,61 @@ var Filter = function(options, impl) {
skip : options . skip ,
skip : options . skip ,
address : options . address
address : options . address
} ;
} ;
} ;
/// Should be used when we want to watch something
/// it's using inner polling mechanism and is notified about changes
/// @param options are filter options
/// @param implementation, an abstract polling implementation
/// @param formatter (optional), callback function which formats output before 'real' callback
var filter = function ( options , implementation , formatter ) {
if ( ! implementationIsValid ( implementation ) ) {
console . error ( 'filter implemenation is invalid' ) ;
return ;
}
}
this . impl = impl ;
options = getOptions ( options ) ;
this . callbacks = [ ] ;
var callbacks = [ ] ;
var filterId = implementation . newFilter ( options ) ;
var onMessages = function ( messages ) {
messages . forEach ( function ( message ) {
message = formatter ? formatter ( message ) : message ;
callbacks . forEach ( function ( callback ) {
callback ( message ) ;
} ) ;
} ) ;
} ;
this . id = impl . newFilter ( options ) ;
implementation . startPolling ( filterId , onMessages , implementation . uninstallFilter ) ;
web3 . provider . startPolling ( { method : impl . changed , params : [ this . id ] } , this . id , this . trigger . bind ( this ) ) ;
} ;
/// alias for changed*
var changed = function ( callback ) {
Filter . prototype . arrived = function ( callback ) {
callbacks . push ( callback ) ;
this . changed ( callback ) ;
} ;
} ;
Filter . prototype . happened = function ( callback ) {
this . changed ( callback ) ;
} ;
/// gets called when there is new eth/shh message
Filter . prototype . changed = function ( callback ) {
this . callbacks . push ( callback ) ;
} ;
/// trigger calling new message from people
var messages = function ( ) {
Filter . prototype . trigger = function ( messages ) {
return implementation . getMessages ( filterId ) ;
for ( var i = 0 ; i < this . callbacks . length ; i ++ ) {
} ;
for ( var j = 0 ; j < messages . length ; j ++ ) {
var message = this . _onWatchResult ? this . _onWatchResult ( messages [ j ] ) : messages [ j ] ;
this . callbacks [ i ] . call ( this , message ) ;
}
}
} ;
/// should be called to uninstall current filter
var uninstall = function ( ) {
Filter . prototype . uninstall = function ( ) {
implementation . stopPolling ( filterId ) ;
this . impl . uninstallFilter ( this . id ) ;
implementation . uninstallFilter ( filterId ) ;
web3 . provider . stopPolling ( this . id ) ;
callbacks = [ ] ;
} ;
} ;
/// should be called to manually trigger getting latest messages from the client
return {
Filter . prototype . messages = function ( ) {
changed : changed ,
return this . impl . getMessages ( this . id ) ;
arrived : changed ,
happened : changed ,
messages : messages ,
logs : messages ,
uninstall : uninstall
} ;
} ;
} ;
/// alias for messages
module . exports = filter ;
Filter . prototype . logs = function ( ) {
return this . messages ( ) ;
} ;
module . exports = Filter ;
} , { "./web3" : 13 } ] , 6 : [ function ( require , module , exports ) {
} , { } ] , 8 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -770,6 +909,7 @@ var padLeft = function (string, chars, sign) {
/// If the value is floating point, round it down
/// If the value is floating point, round it down
/// @returns right-aligned byte representation of int
/// @returns right-aligned byte representation of int
var formatInputInt = function ( value ) {
var formatInputInt = function ( value ) {
/*jshint maxcomplexity:7 */
var padding = c . ETH _PADDING * 2 ;
var padding = c . ETH _PADDING * 2 ;
if ( value instanceof BigNumber || typeof value === 'number' ) {
if ( value instanceof BigNumber || typeof value === 'number' ) {
if ( typeof value === 'number' )
if ( typeof value === 'number' )
@ -883,7 +1023,7 @@ module.exports = {
} ;
} ;
} , { "./const" : 2 , "./utils" : 12 } ] , 7 : [ function ( require , module , exports ) {
} , { "./const" : 2 , "./utils" : 15 } ] , 9 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -923,15 +1063,17 @@ HttpSyncProvider.prototype.send = function (payload) {
request . open ( 'POST' , this . host , false ) ;
request . open ( 'POST' , this . host , false ) ;
request . send ( JSON . stringify ( payload ) ) ;
request . send ( JSON . stringify ( payload ) ) ;
// check request.status
var result = request . responseText ;
var result = request . responseText ;
// check request.status
if ( request . status !== 200 )
return ;
return JSON . parse ( result ) ;
return JSON . parse ( result ) ;
} ;
} ;
module . exports = HttpSyncProvider ;
module . exports = HttpSyncProvider ;
} , { } ] , 8 : [ function ( require , module , exports ) {
} , { } ] , 10 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -998,7 +1140,7 @@ module.exports = {
} , { } ] , 9 : [ function ( require , module , exports ) {
} , { } ] , 11 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1015,7 +1157,42 @@ module.exports = {
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/>.
* /
* /
/ * * @ f i l e p r o v i d e r m a n a g e r . j s
/ * * @ f i l e q t s y n c . j s
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* @ date 2014
* /
var QtSyncProvider = function ( ) {
} ;
QtSyncProvider . prototype . send = function ( payload ) {
var result = navigator . qt . callMethod ( JSON . stringify ( payload ) ) ;
return JSON . parse ( result ) ;
} ;
module . exports = QtSyncProvider ;
} , { } ] , 12 : [ 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/>.
* /
/ * * @ f i l e r e q u e s t m a n a g e r . j s
* @ authors :
* @ authors :
* Jeffrey Wilcke < jeff @ ethdev . com >
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
@ -1024,51 +1201,28 @@ module.exports = {
* @ date 2014
* @ date 2014
* /
* /
var web3 = require ( './web3' ) ;
var jsonrpc = require ( './jsonrpc' ) ;
var jsonrpc = require ( './jsonrpc' ) ;
var c = require ( './const' ) ;
/ * *
/ * *
* Provider manager object prototype
* It ' s responsible for passing messages to providers
* It ' s responsible for passing messages to providers
* If no provider is set it ' s responsible for queuing requests
* It ' s also responsible for polling the ethereum node for incoming messages
* It ' s also responsible for polling the ethereum node for incoming messages
* Default poll timeout is 12 seconds
* Default poll timeout is 1 second
* If we are running ethereum . js inside ethereum browser , there are backend based tools responsible for polling ,
* and provider manager polling mechanism is not used
* /
* /
var ProviderManager = function ( ) {
var requestManager = function ( ) {
this . polls = [ ] ;
var polls = [ ] ;
this . provider = undefined ;
var timeout = null ;
var provider ;
var self = this ;
var poll = function ( ) {
self . polls . forEach ( function ( data ) {
var result = self . send ( data . data ) ;
if ( ! ( result instanceof Array ) || result . length === 0 ) {
return ;
}
data . callback ( result ) ;
} ) ;
setTimeout ( poll , 1000 ) ;
} ;
poll ( ) ;
} ;
/// sends outgoing requests
var send = function ( data ) {
/// @params data - an object with at least 'method' property
ProviderManager . prototype . send = function ( data ) {
var payload = jsonrpc . toPayload ( data . method , data . params ) ;
var payload = jsonrpc . toPayload ( data . method , data . params ) ;
if ( this . provider === undefined ) {
if ( ! provider ) {
console . error ( 'provider is not set' ) ;
console . error ( 'provider is not set' ) ;
return null ;
return null ;
}
}
var result = this . provider . send ( payload ) ;
var result = provider . send ( payload ) ;
if ( ! jsonrpc . isValidResponse ( result ) ) {
if ( ! jsonrpc . isValidResponse ( result ) ) {
console . log ( result ) ;
console . log ( result ) ;
@ -1076,33 +1230,66 @@ ProviderManager.prototype.send = function(data) {
}
}
return result . result ;
return result . result ;
} ;
} ;
/// setups provider, which will be used for sending messages
var setProvider = function ( p ) {
ProviderManager . prototype . set = function ( provider ) {
provider = p ;
this . provider = provider ;
} ;
} ;
/// this method is only used, when we do not have native qt bindings and have to do polling on our own
/*jshint maxparams:4 */
/// should be callled, on start watching for eth/shh changes
var startPolling = function ( data , pollId , callback , uninstall ) {
ProviderManager . prototype . startPolling = function ( data , pollId , callback ) {
polls . push ( { data : data , id : pollId , callback : callback , uninstall : uninstall } ) ;
this . polls . push ( { data : data , id : pollId , callback : callback } ) ;
} ;
} ;
/*jshint maxparams:3 */
/// should be called to stop polling for certain watch changes
var stopPolling = function ( pollId ) {
ProviderManager . prototype . stopPolling = function ( pollId ) {
for ( var i = polls . length ; i -- ; ) {
for ( var i = this . polls . length ; i -- ; ) {
var poll = polls [ i ] ;
var poll = this . polls [ i ] ;
if ( poll . id === pollId ) {
if ( poll . id === pollId ) {
this . polls . splice ( i , 1 ) ;
polls . splice ( i , 1 ) ;
}
}
}
}
} ;
var reset = function ( ) {
polls . forEach ( function ( poll ) {
poll . uninstall ( poll . id ) ;
} ) ;
polls = [ ] ;
if ( timeout ) {
clearTimeout ( timeout ) ;
timeout = null ;
}
poll ( ) ;
} ;
var poll = function ( ) {
polls . forEach ( function ( data ) {
var result = send ( data . data ) ;
if ( ! ( result instanceof Array ) || result . length === 0 ) {
return ;
}
data . callback ( result ) ;
} ) ;
timeout = setTimeout ( poll , c . ETH _POLLING _TIMEOUT ) ;
} ;
poll ( ) ;
return {
send : send ,
setProvider : setProvider ,
startPolling : startPolling ,
stopPolling : stopPolling ,
reset : reset
} ;
} ;
} ;
module . exports = ProviderManager ;
module . exports = request Manager;
} , { "./jsonrpc" : 8 , "./web3" : 13 } ] , 10 : [ function ( require , module , exports ) {
} , { "./const" : 2 , "./jsonrpc" : 10 } ] , 13 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1119,25 +1306,29 @@ module.exports = ProviderManager;
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/>.
* /
* /
/ * * @ f i l e q t s y n c . j s
/ * * @ f i l e s h h . j s
* @ authors :
* @ authors :
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* @ date 2015
* @ date 2014
* /
* /
var QtSyncProvider = function ( ) {
/// @returns an array of objects describing web3.shh api methods
var methods = function ( ) {
return [
{ name : 'post' , call : 'shh_post' } ,
{ name : 'newIdentity' , call : 'shh_newIdentity' } ,
{ name : 'haveIdentity' , call : 'shh_haveIdentity' } ,
{ name : 'newGroup' , call : 'shh_newGroup' } ,
{ name : 'addToGroup' , call : 'shh_addToGroup' }
] ;
} ;
} ;
QtSyncProvider . prototype . send = function ( payload ) {
module . exports = {
var result = navigator . qt . callMethod ( JSON . stringify ( payload ) ) ;
methods : methods
return JSON . parse ( result ) ;
} ;
} ;
module . exports = QtSyncProvider ;
} , { } ] , 11 : [ function ( require , module , exports ) {
} , { } ] , 14 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1218,7 +1409,7 @@ module.exports = {
} ;
} ;
} , { "./formatters" : 6 } ] , 12 : [ function ( require , module , exports ) {
} , { "./formatters" : 8 } ] , 15 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1328,6 +1519,7 @@ var filterEvents = function (json) {
/// TODO: use BigNumber.js to parse int
/// TODO: use BigNumber.js to parse int
/// TODO: add tests for it!
/// TODO: add tests for it!
var toEth = function ( str ) {
var toEth = function ( str ) {
/*jshint maxcomplexity:7 */
var val = typeof str === "string" ? str . indexOf ( '0x' ) === 0 ? parseInt ( str . substr ( 2 ) , 16 ) : parseInt ( str ) : str ;
var val = typeof str === "string" ? str . indexOf ( '0x' ) === 0 ? parseInt ( str . substr ( 2 ) , 16 ) : parseInt ( str ) : str ;
var unit = 0 ;
var unit = 0 ;
var units = c . ETH _UNITS ;
var units = c . ETH _UNITS ;
@ -1362,7 +1554,7 @@ module.exports = {
} ;
} ;
} , { "./const" : 2 } ] , 13 : [ function ( require , module , exports ) {
} , { "./const" : 2 } ] , 16 : [ function ( require , module , exports ) {
/ *
/ *
This file is part of ethereum . js .
This file is part of ethereum . js .
@ -1379,102 +1571,14 @@ module.exports = {
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/>.
* /
* /
/ * * @ f i l e w e b 3 . j s
/ * * @ f i l e w a t c h e s . j s
* @ authors :
* @ authors :
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* @ date 2015
* Gav Wood < g @ ethdev . com >
* @ date 2014
* /
* /
if ( "build" !== 'build' ) { / *
var BigNumber = require ( 'bignumber.js' ) ;
* / }
var utils = require ( './utils' ) ;
/// @returns an array of objects describing web3 api methods
var web3Methods = function ( ) {
return [
{ name : 'sha3' , call : 'web3_sha3' }
] ;
} ;
/// @returns an array of objects describing web3.eth api methods
var ethMethods = function ( ) {
var blockCall = function ( args ) {
return typeof args [ 0 ] === "string" ? "eth_blockByHash" : "eth_blockByNumber" ;
} ;
var transactionCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber' ;
} ;
var uncleCall = function ( args ) {
return typeof args [ 0 ] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber' ;
} ;
var methods = [
{ name : 'balanceAt' , call : 'eth_balanceAt' } ,
{ name : 'register' , call : 'eth_register' } ,
{ name : 'unregister' , call : 'eth_unregister' } ,
{ name : 'stateAt' , call : 'eth_stateAt' } ,
{ name : 'storageAt' , call : 'eth_storageAt' } ,
{ name : 'countAt' , call : 'eth_countAt' } ,
{ name : 'codeAt' , call : 'eth_codeAt' } ,
{ name : 'transact' , call : 'eth_transact' } ,
{ name : 'call' , call : 'eth_call' } ,
{ name : 'block' , call : blockCall } ,
{ name : 'transaction' , call : transactionCall } ,
{ name : 'uncle' , call : uncleCall } ,
{ name : 'compilers' , call : 'eth_compilers' } ,
{ name : 'flush' , call : 'eth_flush' } ,
{ name : 'lll' , call : 'eth_lll' } ,
{ name : 'solidity' , call : 'eth_solidity' } ,
{ name : 'serpent' , call : 'eth_serpent' } ,
{ name : 'logs' , call : 'eth_logs' }
] ;
return methods ;
} ;
/// @returns an array of objects describing web3.eth api properties
var ethProperties = function ( ) {
return [
{ name : 'coinbase' , getter : 'eth_coinbase' , setter : 'eth_setCoinbase' } ,
{ name : 'listening' , getter : 'eth_listening' , setter : 'eth_setListening' } ,
{ name : 'mining' , getter : 'eth_mining' , setter : 'eth_setMining' } ,
{ name : 'gasPrice' , getter : 'eth_gasPrice' } ,
{ name : 'accounts' , getter : 'eth_accounts' } ,
{ name : 'peerCount' , getter : 'eth_peerCount' } ,
{ name : 'defaultBlock' , getter : 'eth_defaultBlock' , setter : 'eth_setDefaultBlock' } ,
{ name : 'number' , getter : 'eth_number' }
] ;
} ;
/// @returns an array of objects describing web3.db api methods
var dbMethods = function ( ) {
return [
{ name : 'put' , call : 'db_put' } ,
{ name : 'get' , call : 'db_get' } ,
{ name : 'putString' , call : 'db_putString' } ,
{ name : 'getString' , call : 'db_getString' }
] ;
} ;
/// @returns an array of objects describing web3.shh api methods
var shhMethods = function ( ) {
return [
{ name : 'post' , call : 'shh_post' } ,
{ name : 'newIdentity' , call : 'shh_newIdentity' } ,
{ name : 'haveIdentity' , call : 'shh_haveIdentity' } ,
{ name : 'newGroup' , call : 'shh_newGroup' } ,
{ name : 'addToGroup' , call : 'shh_addToGroup' }
] ;
} ;
/// @returns an array of objects describing web3.eth.watch api methods
/// @returns an array of objects describing web3.eth.watch api methods
var ethWatchMethods = function ( ) {
var eth = function ( ) {
var newFilter = function ( args ) {
var newFilter = function ( args ) {
return typeof args [ 0 ] === 'string' ? 'eth_newFilterString' : 'eth_newFilter' ;
return typeof args [ 0 ] === 'string' ? 'eth_newFilterString' : 'eth_newFilter' ;
} ;
} ;
@ -1487,7 +1591,7 @@ var ethWatchMethods = function () {
} ;
} ;
/// @returns an array of objects describing web3.shh.watch api methods
/// @returns an array of objects describing web3.shh.watch api methods
var shhWatchMethods = function ( ) {
var shh = function ( ) {
return [
return [
{ name : 'newFilter' , call : 'shh_newFilter' } ,
{ name : 'newFilter' , call : 'shh_newFilter' } ,
{ name : 'uninstallFilter' , call : 'shh_uninstallFilter' } ,
{ name : 'uninstallFilter' , call : 'shh_uninstallFilter' } ,
@ -1495,6 +1599,57 @@ var shhWatchMethods = function () {
] ;
] ;
} ;
} ;
module . exports = {
eth : eth ,
shh : shh
} ;
} , { } ] , 17 : [ 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/>.
* /
/ * * @ f i l e w e b 3 . j s
* @ authors :
* Jeffrey Wilcke < jeff @ ethdev . com >
* Marek Kotewicz < marek @ ethdev . com >
* Marian Oancea < marian @ ethdev . com >
* Gav Wood < g @ ethdev . com >
* @ date 2014
* /
if ( "build" !== 'build' ) { / *
var BigNumber = require ( 'bignumber.js' ) ;
* / }
var eth = require ( './eth' ) ;
var db = require ( './db' ) ;
var shh = require ( './shh' ) ;
var watches = require ( './watches' ) ;
var filter = require ( './filter' ) ;
var utils = require ( './utils' ) ;
var requestManager = require ( './requestmanager' ) ;
/// @returns an array of objects describing web3 api methods
var web3Methods = function ( ) {
return [
{ name : 'sha3' , call : 'web3_sha3' }
] ;
} ;
/// creates methods in a given object based on method description on input
/// creates methods in a given object based on method description on input
/// setups api calls for these methods
/// setups api calls for these methods
var setupMethods = function ( obj , methods ) {
var setupMethods = function ( obj , methods ) {
@ -1502,7 +1657,7 @@ var setupMethods = function (obj, methods) {
obj [ method . name ] = function ( ) {
obj [ method . name ] = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
var args = Array . prototype . slice . call ( arguments ) ;
var call = typeof method . call === 'function' ? method . call ( args ) : method . call ;
var call = typeof method . call === 'function' ? method . call ( args ) : method . call ;
return web3 . provid er. send ( {
return web3 . manag er. send ( {
method : call ,
method : call ,
params : args
params : args
} ) ;
} ) ;
@ -1516,14 +1671,14 @@ var setupProperties = function (obj, properties) {
properties . forEach ( function ( property ) {
properties . forEach ( function ( property ) {
var proto = { } ;
var proto = { } ;
proto . get = function ( ) {
proto . get = function ( ) {
return web3 . provid er. send ( {
return web3 . manag er. send ( {
method : property . getter
method : property . getter
} ) ;
} ) ;
} ;
} ;
if ( property . setter ) {
if ( property . setter ) {
proto . set = function ( val ) {
proto . set = function ( val ) {
return web3 . provid er. send ( {
return web3 . manag er. send ( {
method : property . setter ,
method : property . setter ,
params : [ val ]
params : [ val ]
} ) ;
} ) ;
@ -1533,10 +1688,32 @@ var setupProperties = function (obj, properties) {
} ) ;
} ) ;
} ;
} ;
/*jshint maxparams:4 */
var startPolling = function ( method , id , callback , uninstall ) {
web3 . manager . startPolling ( {
method : method ,
params : [ id ]
} , id , callback , uninstall ) ;
} ;
/*jshint maxparams:3 */
var stopPolling = function ( id ) {
web3 . manager . stopPolling ( id ) ;
} ;
var ethWatch = {
startPolling : startPolling . bind ( null , 'eth_changed' ) ,
stopPolling : stopPolling
} ;
var shhWatch = {
startPolling : startPolling . bind ( null , 'shh_changed' ) ,
stopPolling : stopPolling
} ;
/// setups web3 object, and it's in-browser executed methods
/// setups web3 object, and it's in-browser executed methods
var web3 = {
var web3 = {
_callbacks : { } ,
manager : requestManager ( ) ,
_events : { } ,
providers : { } ,
providers : { } ,
/// @returns ascii string representation of hex value prefixed with 0x
/// @returns ascii string representation of hex value prefixed with 0x
@ -1575,12 +1752,15 @@ var web3 = {
/// @param filter may be a string, object or event
/// @param filter may be a string, object or event
/// @param indexed is optional, this is an object with optional event indexed params
/// @param indexed is optional, this is an object with optional event indexed params
/// @param options is optional, this is an object with optional event options ('max'...)
/// @param options is optional, this is an object with optional event options ('max'...)
watch : function ( filter , indexed , options ) {
/// TODO: fix it, 4 params? no way
if ( filter . _isEvent ) {
/*jshint maxparams:4 */
return filter ( indexed , options ) ;
watch : function ( fil , indexed , options , formatter ) {
if ( fil . _isEvent ) {
return fil ( indexed , options ) ;
}
}
return new web3 . filter ( filter , ethWatch ) ;
return filter ( fil , ethWatch , formatter ) ;
}
}
/*jshint maxparams:3 */
} ,
} ,
/// db object prototype
/// db object prototype
@ -1588,54 +1768,44 @@ var web3 = {
/// shh object prototype
/// shh object prototype
shh : {
shh : {
/// @param filter may be a string, object or event
/// @param filter may be a string, object or event
watch : function ( filter , indexed ) {
watch : function ( fil ) {
return new web3 . filter ( filter , shhWatch ) ;
return filter ( fil , shhWatch ) ;
}
}
} ,
} ,
setProvider : function ( provider ) {
web3 . manager . setProvider ( provider ) ;
} ,
/// Should be called to reset state of web3 object
/// Resets everything except manager
reset : function ( ) {
web3 . manager . reset ( ) ;
}
} ;
} ;
/// setups all api methods
/// setups all api methods
setupMethods ( web3 , web3Methods ( ) ) ;
setupMethods ( web3 , web3Methods ( ) ) ;
setupMethods ( web3 . eth , ethMethods ( ) ) ;
setupMethods ( web3 . eth , eth . methods ( ) ) ;
setupProperties ( web3 . eth , ethProperties ( ) ) ;
setupProperties ( web3 . eth , eth . properties ( ) ) ;
setupMethods ( web3 . db , dbMethods ( ) ) ;
setupMethods ( web3 . db , db . methods ( ) ) ;
setupMethods ( web3 . shh , shhMethods ( ) ) ;
setupMethods ( web3 . shh , shh . methods ( ) ) ;
setupMethods ( ethWatch , watches . eth ( ) ) ;
var ethWatch = {
setupMethods ( shhWatch , watches . shh ( ) ) ;
changed : 'eth_changed'
} ;
setupMethods ( ethWatch , ethWatchMethods ( ) ) ;
var shhWatch = {
changed : 'shh_changed'
} ;
setupMethods ( shhWatch , shhWatchMethods ( ) ) ;
web3 . setProvider = function ( provider ) {
web3 . provider . set ( provider ) ;
} ;
module . exports = web3 ;
module . exports = web3 ;
} , { "./utils " : 12 } ] , "web3" : [ function ( require , module , exports ) {
} , { "./db" : 4 , "./eth" : 5 , "./filter" : 7 , "./requestmanager" : 12 , "./shh" : 13 , "./utils" : 15 , "./watches" : 16 } ] , "web3" : [ function ( require , module , exports ) {
var web3 = require ( './lib/web3' ) ;
var web3 = require ( './lib/web3' ) ;
var ProviderManager = require ( './lib/providermanager' ) ;
web3 . provider = new ProviderManager ( ) ;
web3 . filter = require ( './lib/filter' ) ;
web3 . providers . HttpSyncProvider = require ( './lib/httpsync' ) ;
web3 . providers . HttpSyncProvider = require ( './lib/httpsync' ) ;
web3 . providers . QtSyncProvider = require ( './lib/qtsync' ) ;
web3 . providers . QtSyncProvider = require ( './lib/qtsync' ) ;
web3 . eth . contract = require ( './lib/contract' ) ;
web3 . eth . contract = require ( './lib/contract' ) ;
web3 . abi = require ( './lib/abi' ) ;
web3 . abi = require ( './lib/abi' ) ;
module . exports = web3 ;
module . exports = web3 ;
} , { "./lib/abi" : 1 , "./lib/contract" : 3 , "./lib/filter" : 5 , "./lib/ httpsync" : 7 , "./lib/providermanager" : 9 , "./lib/qtsync" : 10 , "./lib/web3" : 13 } ] } , { } , [ "web3" ] )
} , { "./lib/abi" : 1 , "./lib/contract" : 3 , "./lib/httpsync" : 9 , "./lib/qtsync" : 11 , "./lib/web3" : 17 } ] } , { } , [ "web3" ] )
//# sourceMappingURL=ethereum.js.map
//# sourceMappingURL=ethereum.js.map